Entradas

Mostrando entradas de octubre, 2019

Interfaz con botón de cancelar

Imagen
# -*- coding: utf-8 -*- from Tkinter import * import Tkinter as tk import tkMessageBox global cad def thamb(): hamb = var1.get() cantidad = cant.get() costohamb = 0 if hamb == "Hamburguesa sencilla": costohamb = 15 elif hamb == "Hamburguesa Doble": costohamb = 25 elif hamb == "Hamburguesa triple": costohamb = 35 costo = cantidad * costohamb return costo def comp(): costocomp = 0 cantidadR = cant1.get() cantidadP = cant2.get() cantidadB = cant3.get() refresco = CheckVar1.get() papas = CheckVar2.get() burrito = CheckVar3.get() if refresco == 1: costocomp = costocomp + (15 * cantidadR) if papas == 1: costocomp = costocomp + (20 * cantidadP) if burrito == 1: costocomp = costocomp + (18 * cantidadB) return costocomp def impuesto(): iva = (0.15 * (thamb() + comp())) return iva def limpiarcajas(): cuadrohamb.delete(0, ...

Interfaz grafica con listbox

Imagen
# -*- coding: utf-8 -*- from Tkinter import * import Tkinter as tk import tkMessageBox global cad def thamb(): hamb = var1.get() cantidad = cant.get() if hamb == "Hamburguesa sencilla": costohamb = 15 elif hamb == "Hamburguesa Doble": costohamb = 25 else: costohamb = 35 costo = cantidad * costohamb return costo def comp(): costocomp = 0 cantidadR = cant1.get() cantidadP = cant2.get() cantidadB = cant3.get() refresco = CheckVar1.get() papas = CheckVar2.get() burrito = CheckVar3.get() if refresco == 1: costocomp = costocomp + (15 * cantidadR) if papas == 1: costocomp = costocomp + (20 * cantidadP) if burrito == 1: costocomp = costocomp + (18 * cantidadB) return costocomp def impuesto(): iva = (0.15 * (thamb() + comp())) return iva def listapedido(): cad = "" hamb = var1.get() refresco = CheckVar1.get() papas...

Usuario y password con TkInter

Imagen
# -*- coding: utf-8 -*- from Tkinter import * import tkMessageBox def usercomp(): cuser = user.get() longitud = len(cuser) notnum = cuser.isalnum() if notnum == False: tkMessageBox.showinfo("Error", "El nombre de usuario puede contener solo letras y números") elif longitud < 6: tkMessageBox.showinfo("Error", "El nombre de usuario debe contener al menos 6 caracteres") elif longitud > 12: tkMessageBox.showinfo("Error", "El nombre de usuario no puede contener más de 12 caracteres") elif longitud > 5 and longitud < 13 and notnum == True: return True def clavecomp(): cpasword = pasword.get() validar = False # que se vayan cumpliendo los requisitos uno a uno. long = len(cpasword) # Calcula la longitud de la contraseña espacio = False # variable para identificar espacios mayuscula = False # variable para identificar letras mayúsculas ...

Interfaz con Tkinter #2

Imagen
# -*- coding: utf-8 -*- from Tkinter import * import Tkinter as tk raiz = Tk() raiz.title("ventana primaria") raiz.resizable(1, 1) # para permitir agrandar o no el ancho o la altura con el moyuse # raiz.geometry("500x600") raiz.config(bg="orange") raiz.config(bd=15) raiz.config(relief="groove") miFrame = Frame(raiz) miFrame.pack() miFrame.config(bg="yellow") miFrame.config(bd=10) miFrame.config(relief="sunken") miFrame.config(cursor="hand2") # Etiquetas miLabel1 = Label(miFrame, text="Hamburguesa feliz", fg="red", bg="yellow", font=("Arial Black", 25)).grid(row=0, column=0, pady="4") OrdenH = Label(miFrame, text="Seleccione la hamburguesa", bg=...

Interfaz Con TkInter #1

Imagen
# -*- coding: utf-8 -*- from Tkinter import * raiz=Tk() raiz.title("ventana primaria") raiz.resizable(1,1) #para permitir agrandar o no el ancho o la altura con el moyuse raiz.iconbitmap("descarga.ico") #raiz.geometry("500x600") raiz.config(bg="cyan") raiz.config(bd=15) raiz.config(relief="groove") miFrame=Frame(raiz) miFrame.pack() miFrame.config(bg="pink") miFrame.config(bd=10) miFrame.config(relief="sunken") miFrame.config(cursor="hand2") miLabel1=Label(miFrame, text="Ingrese sus datos", fg="red",bg="pink",font=("Arial",18)).grid(row=0,column=0,pady="4") """Para insertar imagenes en un label es lo suiguiente: miImagen=PhotoImage(file="mouse.gif") Label(miFrame, image=miImagen).grid(row=0,column=1) """ cuadronombre=Entry(miFrame ) cuadronombre.grid(row=1,column=1,pady="1") cuadronombre.config(fg="...

mi figura con pygame

Imagen
# -*- coding: utf-8 -*- import pygame import time pygame.init() running = True window = pygame.display.set_mode((800, 210)) while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False carroseria = (139, 130, 0) ventanas = (139, 130, 85) ruedas = (255, 255, 255) carretera = (255, 255, 255) #carroseria pygame.draw.polygon(window, carroseria, [(60, 160), (280, 160), (280, 100), (240, 100), (220, 60), (140, 60), (100, 100), (60, 100)], 0) #ventanas pygame.draw.polygon(window, ventanas, [(120, 100), (230, 100), (210, 70), (150, 70)], 0) # ruedas pygame.draw.ellipse(window,ruedas,[(100, 130), (50, 60)],1 ) pygame.draw.ellipse(window, ruedas, [(200, 130), (50, 60)], 1) #carretera pygame.draw.polygon(window, carretera, [(0, 220), (1280, 220), (1280, 180), (0, 180)], 0) pygame.display.update()

Perrito con pygame

Imagen
# -*- coding: utf-8 -*- import pygame import time pygame.init() running = True window = pygame.display.set_mode( (1150, 1150) ) while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False cara=(139, 130, 0) orejas=(139, 130, 85) menton=(255, 78, 0) ojos=(255, 255, 255) nariz=(255, 255, 255) pygame.draw.polygon(window,cara,[(415, 50), (235, 490), (365, 625), (755, 625), (850, 500), (700, 50)],0) # orejas pygame.draw.polygon(window,orejas,[(415, 50), (60, 320), (175, 635)],0) pygame.draw.polygon(window,orejas,[(700, 50), (1045, 320), (896, 635)],0) # menton pygame.draw.polygon(window,menton,[(365, 625), (550, 415), (755, 625)],0) # ojos # nariz pygame.draw.line(window, nariz, (50, 50), (75, 75), 4) pygame.draw.line(window, nariz, (75, 75), (25, 25), 4) pygame.draw.line(window, nariz, (25, 25), (50, 50), 4) #pygame.draw.line(window , nariz, (50, 50), (75, 75), 4) #pygame.d...

Menu de figuras de Polygonos

Imagen
#-*- coding: utf-8 -*- from Tkinter import * import tkColorChooser # libreria para obtener la gama de colores # crecion de la ventana principal v0 = Tk() v0.title('Menu de figuras con polygonos') v0.config(bg='black') # bg para el color de fondo de la ventana v0.geometry('200x400') # tamaño de la ventana # funciones def mostrar(num, nombre): # ventana secundaria v1 = Toplevel(v0) v1.title(nombre) v1.protocol('Wn_DELETE_WINDOW', "onexit") # para cerrar la ventana por medio de la cruz if num == 1: # Alngel Barrios panel = Canvas(v1, width=1200, height=200, bg="gray") panel.pack() # carroseria panel.create_polygon(60, 160, 280, 160, 280, 100, 240, 100, 220, 60, 140, 60, 100, 100, 60, 100, width=1, fill="red", outline="black") # ruedas panel.create_oval(140, 180, 80, 120, width=1, fill="#1a1200", outline...

Mi Figura geometrica carro Angel Barrios

Imagen
from Tkinter import * def funcion(seleccion, figura): vs = Toplevel() vs.configure(bg="gray") vs.title(figura) if seleccion == 1: panel = Canvas(vs, width=1200, height=200, bg="gray") panel.pack() # carroseria panel.create_polygon(60, 160, 280, 160, 280, 100, 240, 100, 220, 60, 140, 60, 100, 100, 60, 100, width=1, fill="red", outline="black") # ruedas panel.create_oval(140, 180, 80, 120, width=1, fill="#1a1200", outline="#000000") panel.create_oval(200, 180, 260, 120, width=1, fill="#1a1200", outline="#000000") #ventanas panel.create_polygon(120, 100, 220, 100, 210, 70, 150, 70, width=1, fill="blue", outline="black") #carretera panel.create_polygon(0, 220, 1280, 220, 1280, 180, 0, 180, width=1, fill="black", outline="black") def fu...

boton ocultar

Imagen
from Tkinter import * def funcion(seleccion, figura): vs = Toplevel() vs.configure(bg="gray") vs.title(figura) if seleccion == 1: panel = Canvas(vs, width=1200, height=650, bg="gray") panel.pack() # cara panel.create_polygon(415, 50, 235, 490, 365, 625, 755, 625, 850, 500, 700, 50, width=1, fill="#e0af77", outline="brown") # orejas panel.create_polygon(415, 50, 60, 320, 175, 635, width=1, fill="#bb6400", outline="#000000") panel.create_polygon(700, 50, 1045, 320, 896, 635, width=1, fill="#bb6400", outline="#000000") # menton panel.create_polygon(365, 625, 550, 415, 755, 625, width=1, fill="#bb6400", outline="#000000") # ojos panel.create_oval(420, 225, 480, 305, width=1, fill="#1a1200", outline="#000000") panel.create_oval(630, ...