Mundo em Python

Sistema de Café simple (usando tkinter)

from tkinter import*

root = Tk()
root.geometry("890x580+0+0")
root.title("Simples Sistema de Café")
root.resizable(False,False)
def funprecos():
outraroot = Tk()
outraroot.title("Lista de Preços")
outraroot.geometry("500x500")
outraroot.resizable(False,False)
lblinfo = Label(outraroot,font=('aria', 15, 'bold'), text="Produto", fg="black", bd=5)
lblinfo.place(relx=0.05,rely=0.05)
lblinfo = Label(outraroot, font=('aria', 15, 'bold'), text="_____________", fg="white")
lblinfo.place(relx=0.3,rely=0.05)
lblinfo = Label(outraroot, font=('aria', 15, 'bold'), text="Preço", fg="black")
lblinfo.place(relx=0.65, rely=0.05)
lblbebida = Label(outraroot, font=('aria', 15, 'bold'), text="Bebida", fg="blue")
lblbebida.place(relx=0.05, rely=0.15)
lblbebidapreco = Label(outraroot, font=('aria', 15, 'bold'), text="3€", fg="red")
lblbebidapreco.place(relx=0.65, rely=0.15)
lblbatatasfritas = Label(outraroot, font=('aria', 15, 'bold'), text="Batatas Fritas", fg="blue")
lblbatatasfritas.place(relx=0.05, rely=0.25)
lblbatatasfritaspreco = Label(outraroot, font=('aria', 15, 'bold'), text="5€", fg="red")
lblbatatasfritaspreco.place(relx=0.65, rely=0.25)
lblpizzas = Label(outraroot, font=('aria', 15, 'bold'), text="Pizza Famaliar", fg="blue")
lblpizzas.place(relx=0.05, rely=0.35)
lblpizzaspreco = Label(outraroot, font=('aria', 15, 'bold'), text="10€", fg="red")
lblpizzaspreco.place(relx=0.65, rely=0.35)
lblcachorro = Label(outraroot, font=('aria', 15, 'bold'), text="Cachorro", fg="blue")
lblcachorro.place(relx=0.05, rely=0.45)
lblcachorropreco = Label(outraroot, font=('aria', 15, 'bold'), text="6€", fg="red")
lblcachorropreco.place(relx=0.65, rely=0.45)
lblbifana = Label(outraroot, font=('aria', 15, 'bold'), text="Bifana", fg="blue")
lblbifana.place(relx=0.05, rely=0.55)
lblbifanapreco = Label(outraroot, font=('aria', 15, 'bold'), text="7€", fg="red")
lblbifanapreco.place(relx=0.65, rely=0.55)
lblhamburger = Label(outraroot, font=('aria', 15, 'bold'), text="Hamburger ", fg="blue")
lblhamburger.place(relx=0.05, rely=0.65)
lblhamburger = Label(outraroot, font=('aria', 15, 'bold'), text="7€", fg="red")
lblhamburger.place(relx=0.65, rely=0.65)
btnexit2 = Button(outraroot,fg="black", font=('ariel', 16, 'bold'), text="EXIT", bg="red", command=outraroot.destroy)
btnexit2.place(relx=0.25, rely=0.8, relwidth=0.5)
outraroot.mainloop()
def resultado():
bebida=variavel_bebida.get()
batafritas=variavel_batatasfritas.get()
pizzas= variavel_pizza.get()
cachorros=variavel_cachorro.get()
bifanas=variavel_bifana.get()
hamburgeres=variavel_hamburger.get() custodabebebida = bebida * 3
custodabatafritas = batafritas * 5
custospizzas = pizzas * 10
custoscachorros = cachorros * 6
custosbifanas = bifanas * 7
custoshamburgeres = hamburgeres * 7


a = custodabebebida + custodabatafritas + custospizzas + custoscachorros\
+ custosbifanas + custoshamburgeres
pagamentoimposto = ((custodabebebida+custodabatafritas+
custospizzas+custoscachorros+custosbifanas+ custoshamburgeres)*0.33)
Gorjeta=((custodabebebida +
custodabatafritas + custospizzas + custoscachorros
+ custosbifanas + custoshamburgeres)*0.1)
t = round((a + pagamentoimposto +Gorjeta),2)
tar = str(t) custorefeição = str(
'%.2f' % (a)+' €')
pagamentogorjeta = str('%.2f' % Gorjeta), '€'
totalidade = str(tar), '€'
timposto = str('%.2f' % pagamentoimposto), '€'

subtotal.set(custorefeição)
servico.set(pagamentogorjeta)
impostos.set(timposto)
total.set(totalidade)
def limpeza ():
variavel_bebida.set("0")
variavel_batatasfritas.set("0")
variavel_pizza.set("0")
variavel_cachorro.set("0")
variavel_bifana.set("0")
variavel_hamburger.set("0")
servico.set("")
impostos.set("")
total.set("")
subtotal.set("") titulo = Label(font=('aria' ,30, 'bold'),text="Simples Sistema de Café",fg="Black")
titulo.place(relx=0.25,rely=0.05)
variavel_bebida = IntVar()
variavel_batatasfritas = IntVar()
variavel_pizza = IntVar()
variavel_cachorro = IntVar()
variavel_bifana = IntVar()
variavel_hamburger = IntVar()
bebida = Label( font=( 'aria' ,16, 'bold' ),text=" Bebida ",fg="blue",bd=10)
bebida.place(relx=0.05,rely=0.2)
entradas_bebida = Entry(font=('ariel' ,16,'bold'),
textvariable=variavel_bebida,
bg="green",justify='center')
entradas_bebida.place(relx=0.25,rely=0.22,relwidth=0.1) batatasfritas = Label( font=( 'aria' ,16, 'bold' ),
text=" Batatas Fritas ",fg="blue",bd=10)
batatasfritas.place(relx=0.05,rely=0.3)
entradas_batatasfritas = Entry(font=('ariel' ,16,'bold'),
textvariable=variavel_batatasfritas,
bg="green",justify='center')
entradas_batatasfritas.place(relx=0.25,rely=0.32,relwidth=0.1) pizza = Label( font=('aria' ,16,'bold'),text="Pizza",fg="blue",bd=10)
pizza.place(relx=0.05,rely=0.4)
entradas_pizza = Entry(font=('ariel' ,16,'bold'),
textvariable=variavel_pizza,
bg="green",justify='center')
entradas_pizza.place(relx=0.25,rely=0.42,relwidth=0.1) cachorro = Label( font=('aria' ,16,'bold'),text="Cachorro",fg="blue",bd=10)
cachorro.place(relx=0.05,rely=0.5)
entradas_cachorro = Entry(font=('ariel' ,16,'bold'),
textvariable=variavel_cachorro,
bg="green",justify='center')
entradas_cachorro.place(relx=0.25,rely=0.52,relwidth=0.1) bifana = Label( font=('aria' ,16,'bold'),text="Bifana",fg="blue",bd=10)
bifana.place(relx=0.05,rely=0.6)
entradas_bifana = Entry(font=('ariel' ,16,'bold'),
textvariable=variavel_bifana,
bg="green",justify='center')
entradas_bifana.place(relx=0.25,rely=0.62,relwidth=0.1)
hamburger = Label( font=('aria' ,16,'bold'),text="Hamburger",fg="blue",bd=10)
hamburger.place(relx=0.05,rely=0.7)
entradas_hamburger = Entry(font=('ariel' ,16,'bold'),
textvariable=variavel_hamburger,
bg="green",justify='center')
entradas_hamburger.place(relx=0.25,rely=0.72,relwidth=0.1) #--------------------------------------------------------------------------------------
servico = StringVar()
impostos = StringVar()
total = StringVar()
subtotal = StringVar() lblcusto = Label( font=( 'aria' ,16, 'bold' ),text="Subtotal",fg="black")
lblcusto.place(relx=0.5,rely=0.42)
txtcusto = Label(font=('ariel' ,16,'bold'), textvariable=subtotal,
bd=6,bg="white",fg="black",justify='center')
txtcusto.place(relx=0.62,rely=0.42,relwidth=0.25) lblservico = Label( font=( 'aria' ,16, 'bold' ),text="Gorjeta",fg="black")
lblservico.place(relx=0.5,rely=0.52)
txtserviço = Label(font=('ariel' ,16,'bold'), textvariable=servico,
bd=6,bg="white",fg="black",justify='center')
txtserviço.place(relx=0.62,rely=0.52,relwidth=0.25) lblimpostos = Label( font=( 'aria' ,16, 'bold' ),text="Impostos",fg="black")
lblimpostos.place(relx=0.5,rely=0.62)
txtimpostos = Label(font=('ariel' ,16,'bold'), textvariable=impostos,
bd=6,bg="white",fg="black",justify='center')
txtimpostos.place(relx=0.62,rely=0.62,relwidth=0.25) lbltotal = Label( font=( 'aria' ,16, 'bold' ),text="Total",fg="black")
lbltotal.place(relx=0.5,rely=0.72)
txttotal = Label(font=('ariel' ,16,'bold'), textvariable=total,
bd=6,bg="white",fg="red",justify='center')
txttotal .place(relx=0.62,rely=0.72,relwidth=0.25) # Butão
btnprecos=Button(fg="black",font=('ariel' ,16,'bold'),
text="PREÇOS", bg="blue",justify='center',command=funprecos)
btnprecos.place(relx=0.05,rely=0.9,relwidth=0.2) #
btnTotal=Button(fg="black",font=('ariel' ,16,'bold'),
text="TOTAL", bg="green",justify='center',command=resultado)
btnTotal.place(relx=0.3,rely=0.9,relwidth=0.2)
btnlimpar=Button(fg="black",font=('ariel' ,16,'bold'),
text="RESET", bg="Orange",command=limpeza )
btnlimpar.place(relx=0.52,rely=0.9,relwidth=0.2) btnexit=Button(fg="black",font=('ariel' ,16,'bold'),
text="EXIT", bg="red",command=root.destroy)
btnexit.place(relx=0.75,rely=0.9,relwidth=0.2)
root.mainloop()
0