|
# -*- 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 = CheckVar2.get() |
|
burrito = CheckVar3.get() |
|
listpedido = Listbox(miFrame, width=50) |
|
if hamb == "Hamburguesa sencilla": |
|
cad += "Hamburguesa sencilla $15 c/u" |
|
elif hamb == "Hamburguesa Doble": |
|
cad += "Hamburguesa Doble $25 c/u" |
|
else: |
|
cad += "Hamburguesa triple $35 c/u" |
|
listpedido.insert(0, cad) |
|
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") |
|
listpedido.grid(row=2, column=2, pady="1", padx="4") |
|
|
|
|
|
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="light blue", font=("Arial", 14), ).grid(row=9, column=2, pady="1", |
|
padx="15", sticky="w") |
|
riva = Label(miFrame, text=iva, bg="light blue", font=("Arial", 14)).grid(row=8, column=2, pady="1", padx="15", |
|
sticky="w") |
|
rtotal = Label(miFrame, text=totali(), bg="light blue", 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.geometry("500x600") |
|
raiz.config(bg="orange") |
|
raiz.config(bd=15) |
|
raiz.config(relief="groove") |
|
|
|
miFrame = Frame(raiz) |
|
miFrame.pack() |
|
miFrame.config(bg="light blue") |
|
miFrame.config(bd=10) |
|
miFrame.config(relief="sunken") |
|
miFrame.config(cursor="hand2") |
|
# Etiquetas |
|
miLabel1 = Label(miFrame, text="Hamburguesa feliz", fg="Black", bg="light blue", font=("Arial Black", 30)).grid(row=0, |
|
column=0, |
|
pady="4") |
|
OrdenH = Label(miFrame, text="Seleccione la hamburguesa", bg="light blue", font=("Arial", 14)).grid(row=1, column=0, |
|
pady="1", padx="15", |
|
sticky="w") |
|
Pedido = Label(miFrame, text="Pedido:", bg="light blue", font=("Arial", 14)).grid(row=1, column=2, pady="1") |
|
cantidadhamb = Label(miFrame, text="Cantidad de Hamburguesas:", bg="light blue", font=("Arial", 14)).grid(row=2, column=0, |
|
pady="1", |
|
padx="15", |
|
sticky="w") |
|
complementos = Label(miFrame, text="Complementos:", bg="light blue", font=("Arial", 14)).grid(row=3, column=0, pady="1", |
|
padx="15", sticky="w") |
|
Cantidadcomp = Label(miFrame, text="Cantidad complementos:", bg="light blue", font=("Arial", 14)).grid(row=3, column=1, |
|
pady="1", padx="15", |
|
sticky="w") |
|
Formadepago = Label(miFrame, text="Forma de pago:", bg="light blue", font=("Arial", 14)).grid(row=7, column=0, pady="1", |
|
padx="15", sticky="w") |
|
Total = Label(miFrame, text="Total:", bg="light blue", font=("Arial", 14)).grid(row=7, column=1, pady="1", padx="15", |
|
sticky="w") |
|
IVA = Label(miFrame, text="IVA:", bg="light blue", font=("Arial", 14)).grid(row=8, column=1, pady="1", padx="15", |
|
sticky="w") |
|
TotalFinal = Label(miFrame, text="Total final:", bg="light blue", font=("Arial", 14)).grid(row=9, column=1, pady="1", |
|
padx="15", sticky="w") |
|
|
|
# Lista de opciones despegable |
|
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) |
|
cant1 = tk.IntVar(miFrame) |
|
cant2 = tk.IntVar(miFrame) |
|
cant3 = tk.IntVar(miFrame) |
|
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="light blue", variable=CheckVar1) |
|
Refresco.grid(row=4, column=0, sticky="w", padx="15") |
|
Refresco.config(onvalue=1, offvalue=0) |
|
Papas = Checkbutton(miFrame, text="Papas", bg="light blue", variable=CheckVar2) |
|
Papas.grid(row=5, column=0, sticky="w", padx="15") |
|
Papas.config(onvalue=1, offvalue=0) |
|
Burrito = Checkbutton(miFrame, text="Burrito", bg="light blue", 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="light blue", variable=var, value=1) # , command=sel) |
|
R1.grid(row=8, column=0, sticky="w", padx="15") |
|
R2 = Radiobutton(miFrame, text="Efectivo", bg="light blue", variable=var, value=2) # , command=sel) |
|
R2.grid(row=9, column=0, sticky="w", padx="15") |
|
|
|
# botones |
|
Cancelar = Button(miFrame, text="Cancelar", command=totalf) |
|
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