Conta de restaurante simples (usando tkinter)

from tkinter import *
root = Tk()
root.geometry('800x650')
root.resizable(0, 0)
root.title('Programa Simples Restaurante')
titulo = Label(text="Programa Simples Restaurante ", font=('arial', 18, 'bold'),bg='firebrick4',fg="#d4af37")
titulo.place(relx=0.3,rely=0.05)
def vbatatasfrias1():
if var1.get() == 1:
textbatatasfrias.config(state=NORMAL)
textbatatasfrias.focus()
textbatatasfrias.delete(0, END)
elif var1.get() == 0:
textbatatasfrias.config(state=DISABLED)
textbatatasfrias.set('0')

def vcachorro1():
if var2.get() == 1:
textcachorro.config(state=NORMAL)
textcachorro.focus()
textcachorro.delete(0, END)
elif var2.get() == 0:
textcachorro.config(state=DISABLED)
textcachorro.set('0')
def vhamburge1():
if var3.get() == 1:
texthamburger.config(state=NORMAL)
texthamburger.focus()
texthamburger.delete(0, END)
elif var3.get() == 0:
texthamburger.config(state=DISABLED)
texthamburger.set('0')
def vcompal1():
if var4.get() == 1:
textcompal.config(state=NORMAL)
textcompal.focus()
textcompal.delete(0, END)
elif var4.get() == 0:
textcompal.config(state=DISABLED)
textcompal.set('0')
def vicetea1():
if var5.get() == 1:
texticetea.config(state=NORMAL)
texticetea.focus()
texticetea.delete(0, END)
elif var5.get() == 0:
texticetea.config(state=DISABLED)
texticetea.set('0')
def vcola1():
if var6.get() == 1:
textcola.config(state=NORMAL)
textcola.focus()
textcola.delete(0, END)
elif var6.get() == 0:
textcola.config(state=DISABLED)
textcola.set('0')
def totalcost ():
vbatatasfrias2 = int(vbatatasfrias.get())
vcola2 = int(vcola.get())
vcachorro2 = int(vcachorro.get())
vhamburger2 = int(vhamburger.get())
vcompal2 = int(vcompal.get())
vice2 = int(vice.get())
precobatatasfrias = 3
precocachorro = 5
precohanburger = 6
precocompal = 1.5
precoice = 1.2
precocola = 1.6
total = round((vbatatasfrias2*precobatatasfrias+vcola2*precocola+vcachorro2*precocachorro+
vhamburger2*precohanburger+vcompal2*precocompal+vice2*precoice),2)
totalcomida = round((vbatatasfrias2*precobatatasfrias + vcachorro2*precocachorro
+ vhamburger2*precohanburger),2)
totalbebida = round((vcompal2*precocompal +vice2*precoice + vcola2*precocola),2)

iva = round((total*0.13),2)
totalf = iva + total
custototal.set(totalf),custoiva.set(iva),custosemiva.set(total),\
totaldocomida.set(totalcomida),totaldobebida.set(totalbebida)

def limpar():
textbatatasfrias.delete(0, END)
textcachorro.delete(0, END)
texthamburger.delete(0, END)
textcompal.delete(0, END)
textcola.delete(0, END)
texticetea.delete(0, END)
def quit():
root.quit()

var1 = IntVar()
var2 = IntVar()
var3 = IntVar()
var4 = IntVar()
var5 = IntVar()
var6 = IntVar()
vbatatasfrias = StringVar()
vcola = StringVar()
vcachorro = StringVar()
vhamburger = StringVar()
vcompal = StringVar()
vice = StringVar()

vbatatasfrias.set('0')
vcola.set('0')
vcachorro.set('0')
vhamburger.set('0')
vcompal.set('0')
vice.set('0')
batatasfrias = Checkbutton(text='Batatas Fritas', font=('arial', 15, 'bold'),
onvalue=1, offvalue=0,bg='firebrick4',
variable=var1,command=vbatatasfrias1)
batatasfrias.place(relx=0.05,rely=0.2)



textbatatasfrias = Entry(root,font=('arial', 12, 'bold'), bd=7, width=6, state=DISABLED,
textvariable=vbatatasfrias,justify='center')
textbatatasfrias.place(relx=0.35,rely=0.2)

cachorro = Checkbutton(text='Cachorro', font=('arial', 15, 'bold'), onvalue=1,
offvalue=0,bg='firebrick4',variable=var2,command=vcachorro1)
cachorro.place(relx=0.05,rely=0.3)
textcachorro = Entry(root,font=('arial', 12, 'bold'), bd=7, width=6, state=DISABLED,
textvariable=vcachorro, justify='center')
textcachorro.place(relx=0.35,rely=0.3)
hamburger = Checkbutton(text='Hamburger', font=('arial', 15, 'bold'), onvalue=1,
offvalue=0,bg='firebrick4', variable=var3,command=vhamburge1)
hamburger.place(relx=0.05,rely=0.4)
texthamburger = Entry(root,font=('arial', 12, 'bold'), bd=7, width=6,
state=DISABLED, textvariable=vhamburger,justify='center')
texthamburger.place(relx=0.35,rely=0.4)
compal = Checkbutton(text='Compal', font=('arial', 15, 'bold'),
onvalue=1, offvalue=0,bg='firebrick4', variable=var4,command=vcompal1)
compal.place(relx=0.05,rely=0.5)
textcompal = Entry(root,font=('arial', 12, 'bold'), bd=7, width=6,
state=DISABLED, textvariable=vcompal, justify='center')
textcompal.place(relx=0.35,rely=0.5)

icetea = Checkbutton(text='Icetea', font=('arial', 15, 'bold'),
onvalue=1, offvalue=0,bg='firebrick4', variable=var5,command=vicetea1)
icetea.place(relx=0.05,rely=0.6)
texticetea = Entry(root,font=('arial', 12, 'bold'), bd=7, width=6,
state=DISABLED, textvariable=vice, justify='center')
texticetea.place(relx=0.35,rely=0.6)
cola = Checkbutton(text='Coca-Cola', font=('arial', 15, 'bold'),
onvalue=1, offvalue=0,bg='firebrick4', variable=var6,command=vcola1)
cola.place(relx=0.05,rely=0.7)

textcola = Entry(root,font=('arial', 12, 'bold'), bd=7, width=6,
state=DISABLED, textvariable=vcola, justify='center')
textcola.place(relx=0.35,rely=0.7)
#

buttonTotal = Button( text='Total', font=('arial', 14, 'bold'),
fg='white', bg='green', bd=3, padx=5,command=totalcost)
buttonTotal.place(relx=0.35,rely=0.85)

#
buttonlimpar = Button( text='Limpar', font=('arial', 14, 'bold'),
fg='white', bg='green', bd=3, padx=5,command=limpar)
buttonlimpar.place(relx=0.5,rely=0.85)
#quit

buttonsair = Button( text='Exit', font=('arial', 14, 'bold'),
fg='white', bg='green', bd=3, padx=5,command=quit)
buttonsair.place(relx=0.65,rely=0.85)


custototal = StringVar()
resultado=Label( text="Resultado Total",font=("Arial","11","bold"))
resultado.place(relx=0.62,rely=0.2)
resultadof=Label( textvariable=custototal)
resultadof.place(relx=0.6,rely=0.25,relwidth=0.2)

custoiva = StringVar()
resultadoiva=Label( text="Total de IVA",font=("Arial","11","bold"))
resultadoiva.place(relx=0.64,rely=0.32)
resultadofiva=Label( textvariable=custoiva)
resultadofiva.place(relx=0.6,rely=0.37,relwidth=0.2)

custosemiva = StringVar()
resultadosemiva=Label( text="Total sem IVA",font=("Arial","11","bold"))
resultadosemiva.place(relx=0.64,rely=0.45)
resultadofsemiva=Label( textvariable=custosemiva)
resultadofsemiva.place(relx=0.6,rely=0.5,relwidth=0.2)
totaldocomida = StringVar()
resultadototaldocomida=Label( text="Total da Comida",font=("Arial","11","bold"))
resultadototaldocomida.place(relx=0.62,rely=0.58)
resultadoftotaldocomida=Label( textvariable=totaldocomida)
resultadoftotaldocomida.place(relx=0.6,rely=0.63,relwidth=0.2)
totaldobebida = StringVar()
resultadototaldabebida=Label( text="Total da Bebida",font=("Arial","11","bold"))
resultadototaldabebida.place(relx=0.62,rely=0.7)
resultadoftotalbebida=Label( textvariable=totaldobebida)
resultadoftotalbebida.place(relx=0.6,rely=0.75,relwidth=0.2)
root.config(bg='firebrick4')
root.mainloop()

Comentários

Mensagens populares deste blogue

Criar Cartões de Visita

12 signos egípcios

Calcular a percentagem de ocupação