# -*- 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, 'end')
cuadrorefresco.delete(0,'end')
cuadroburrito.delete(0,'end')
cuadropapas.delete(0,'end')
limpiarbotones()
def limpiarbotones():
var1.set("No ha selecionado")
CheckVar1.set(None)
CheckVar2.set(None)
CheckVar3.set(None)
var.set(None)
rtotalfinal = Label(miFrame, text=" ", bg="yellow", font=("Arial", 14), ).grid(row=9, column=2, pady="1",padx="15", sticky="w")
riva = Label(miFrame, text=" ", bg="yellow", font=("Arial", 14)).grid(row=8, column=2, pady="1", padx="15", sticky="w")
rtotal = Label(miFrame, text=" ", bg="yellow", font=("Arial", 14)).grid(row=7, column=2, pady="1", padx="15", sticky="w")
limpiarlistapedido()
def listapedido():
cad=""
hamb = var1.get()
refresco = CheckVar1.get()
papas = CheckVar2.get()
burrito = CheckVar3.get()
listpedido = Listbox(miFrame, width=50)
if hamb != "No ha selecionado" or refresco ==1 or papas ==1 or burrito ==1:
if hamb == "Hamburguesa sencilla":
cad += "Hamburguesa sencilla $15 c/u"
elif hamb == "Hamburguesa Doble":
cad += "Hamburguesa Doble $25 c/u"
elif hamb == "Hamburguesa triple":
cad += "Hamburguesa triple $35 c/u"
listpedido.insert(0, cad)
# insert
if refresco == 1:
listpedido.insert(1, "Refresco $15 c/u")
if papas == 1:
listpedido.insert(2, "Papas $20 c/u")
if burrito == 1:
listpedido.insert(3, "Burrito $18 c/u")
#DELETE
elif hamb == "No ha selecionado" and refresco == 0 and papas == 0 and burrito == 0:
listpedido.delete(0)
listpedido.delete(1)
listpedido.delete(2)
listpedido.delete(3)
listpedido.grid(row=2, column=2, pady="1", padx="4")
def limpiarlistapedido():
cant.set(0)
cant1.set(0)
cant2.set(0)
cant3.set(0)
CheckVar1.set(0)
CheckVar2.set(0)
CheckVar3.set(0)
listapedido()
tkMessageBox.showinfo("Cancelacion exitosa", "Se ha cancelado el pedido, y esta listo para realizar nuevo pedido")
def totali():
total=thamb()+comp()
return total
def totalf():
formapago=var.get()
totf=0
if formapago ==1:
totf=totali()+impuesto()
iva=impuesto()
elif formapago ==2:
totf=totali()
iva=0
rtotalfinal = Label(miFrame, text=totf, bg="yellow", font=("Arial", 14), ).grid(row=9, column=2, pady="1", padx="15",sticky="w")
riva = Label(miFrame, text=iva, bg="yellow", font=("Arial", 14)).grid(row=8, column=2, pady="1", padx="15",sticky="w")
rtotal = Label(miFrame, text=totali(), bg="yellow", font=("Arial", 14)).grid(row=7, column=2, pady="1", padx="15",sticky="w")
listapedido()
def ocultar(ventana): ventana.withdraw()
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("Hamburger.ico")
#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="yellow",font=("Arial",14)).grid(row=1,column=0,pady="1",padx="15", sticky="w")
Pedido=Label(miFrame, text="Pedido:", bg="yellow",font=("Arial",14)).grid(row=1,column=2,pady="1")
cantidadhamb=Label(miFrame, text="Cantidad de Hamburguesas:", bg="yellow",font=("Arial",14)).grid(row=2,column=0,pady="1",padx="15", sticky="w")
complementos=Label(miFrame, text="Complementos:", bg="yellow",font=("Arial",14)).grid(row=3,column=0,pady="1",padx="15", sticky="w")
Cantidadcomp=Label(miFrame, text="Cantidad complementos:", bg="yellow",font=("Arial",14)).grid(row=3,column=1,pady="1",padx="15", sticky="w")
Formadepago=Label(miFrame, text="Forma de pago:", bg="yellow",font=("Arial",14)).grid(row=7,column=0,pady="1",padx="15", sticky="w")
Total=Label(miFrame, text="Total:", bg="yellow",font=("Arial",14)).grid(row=7,column=1,pady="1",padx="15", sticky="w")
IVA=Label(miFrame, text="IVA:", bg="yellow",font=("Arial",14)).grid(row=8,column=1,pady="1",padx="15", sticky="w")
TotalFinal=Label(miFrame, text="Total final:", bg="yellow",font=("Arial",14)).grid(row=9,column=1,pady="1",padx="15", sticky="w")
#Lista de opciones desplegable
var1=tk.StringVar(miFrame)
var1.set("No ha selecionado")
opciones=["Hamburguesa sencilla","Hamburguesa Doble","Hamburguesa triple"]
opcion=tk.OptionMenu(miFrame,var1,*opciones)
opcion.config(width=20)
opcion.grid(row=1,column=1)
c= Listbox(miFrame, width=50).grid(row=2, column=2, pady="1", padx="4")
#Entrys
cant=tk.IntVar(miFrame)
cant.set(0)
cant1=tk.IntVar(miFrame)
cant1.set(0)
cant2=tk.IntVar(miFrame)
cant2.set(0)
cant3=tk.IntVar(miFrame)
cant3.set(0)
cuadrohamb=Entry(miFrame, textvariable=cant )
cuadrohamb.grid(row=2,column=1,pady="1")
cuadrohamb.config(fg="blue", justify="center")
cuadrorefresco=Entry(miFrame, textvariable=cant1 )
cuadrorefresco.grid(row=4,column=1,pady="1")
cuadrorefresco.config(fg="blue", justify="center")
cuadropapas=Entry(miFrame,textvariable=cant2 )
cuadropapas.grid(row=5,column=1,pady="1")
cuadropapas.config(fg="blue", justify="center")
cuadroburrito=Entry(miFrame,textvariable=cant3 )
cuadroburrito.grid(row=6,column=1,pady="1")
cuadroburrito.config(fg="blue", justify="center")
#Checkbutton
CheckVar1=IntVar()
CheckVar2=IntVar()
CheckVar3=IntVar()
Refresco=Checkbutton(miFrame,text="Refresco",bg="yellow", variable=CheckVar1)
Refresco.grid(row=4,column=0, sticky="w",padx="15")
Refresco.config(onvalue=1, offvalue=0)
Papas=Checkbutton(miFrame,text="Papas", bg="yellow",variable=CheckVar2)
Papas.grid(row=5,column=0, sticky="w",padx="15")
Papas.config(onvalue=1, offvalue=0)
Burrito=Checkbutton(miFrame,text="Burrito",bg="yellow", variable=CheckVar3)
Burrito.grid(row=6,column=0, sticky="w",padx="15")
Burrito.config(onvalue=1, offvalue=0)
#Radiobutton
var = IntVar()
R1 = Radiobutton(miFrame, text="Tarjeta de credito",bg="yellow", variable=var, value=1)#, command=sel)
R1.grid(row=8,column=0, sticky="w",padx="15")
R2 = Radiobutton(miFrame, text="Efectivo",bg="yellow", variable=var, value=2) #, command=sel)
R2.grid(row=9,column=0, sticky="w",padx="15")
#botones
Cancelar=Button(miFrame, text= "Cancelar",command=limpiarcajas)
Cancelar.grid(row=10,column=0, sticky="w",padx="15")
Comprar=Button(miFrame, text= "Hacer pedido", bg="Green",command=totalf)
Comprar.grid(row=10,column=2, sticky="e",padx="15")
Terminar=Button(raiz, text= "Terminar", bg="Red", command=lambda: ocultar(raiz))
Terminar.pack()
raiz.mainloop()
Comentarios
Publicar un comentario