from tkinter import *
root = Tk()
root.geometry('500x600')
root.resizable(0, 0)
root.title('Calculadora muito Simples')
titulo = Label(text="Calculadora muito Simples ", font=('arial', 18, 'bold'),bg='firebrick4',fg="#d4af37")
titulo.place(relx=0.2,rely=0.05)
def vpao1():
if var1.get() == 1:
textpao.config(state=NORMAL)
textpao.focus()
textpao.delete(0, END)
elif var1.get() == 0:
textpao.config(state=DISABLED)
textpao.set('0')
def vfiambre1():
if var2.get() == 1:
textfiambre.config(state=NORMAL)
textfiambre.focus()
textfiambre.delete(0, END)
elif var2.get() == 0:
textfiambre.config(state=DISABLED)
textfiambre.set('0')
def vnatas1():
if var3.get() == 1:
textnatas.config(state=NORMAL)
textnatas.focus()
textnatas.delete(0, END)
elif var3.get() == 0:
textnatas.config(state=DISABLED)
textnatas.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 ():
vpao2 = int(vpao.get())
vcola2 = int(vcola.get())
vfiambre2 = int(vfiambre.get())
vnatas2 = int(vnatas.get())
vcompal2 = int(vcompal.get())
vice2 = int(vice.get())
total = vpao2*0.5+vcola2*1.5+vfiambre2*1.65+vnatas2*0.35+vcompal2*1.6+vice2*1.6
custototal.set(total)
var1 = IntVar()
var2 = IntVar()
var3 = IntVar()
var4 = IntVar()
var5 = IntVar()
var6 = IntVar()
vpao = StringVar()
vcola = StringVar()
vfiambre = StringVar()
vnatas = StringVar()
vcompal = StringVar()
vice = StringVar()
vpao.set('0')
vcola.set('0')
vfiambre.set('0')
vnatas.set('0')
vcompal.set('0')
vice.set('0')
pao = Checkbutton(text='Pão', font=('arial', 15, 'bold'), onvalue=1, offvalue=0,bg='firebrick4',
variable=var1,command=vpao1)
pao.place(relx=0.05,rely=0.2)
textpao = Entry(root,font=('arial', 12, 'bold'), bd=7, width=6, state=DISABLED,
textvariable=vpao,justify='center')
textpao.place(relx=0.35,rely=0.2)
fiambre = Checkbutton(text='Fiambre', font=('arial', 15, 'bold'), onvalue=1,
offvalue=0,bg='firebrick4',variable=var2,command=vfiambre1)
fiambre.place(relx=0.05,rely=0.3)
textfiambre = Entry(root,font=('arial', 12, 'bold'), bd=7, width=6, state=DISABLED,
textvariable=vfiambre, justify='center')
textfiambre.place(relx=0.35,rely=0.3)
natas = Checkbutton(text='Natas', font=('arial', 15, 'bold'), onvalue=1,
offvalue=0,bg='firebrick4', variable=var3,command=vnatas1)
natas.place(relx=0.05,rely=0.4)
textnatas = Entry(root,font=('arial', 12, 'bold'), bd=7, width=6,
state=DISABLED, textvariable=vnatas,justify='center')
textnatas.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.75,rely=0.2)
custototal = StringVar()
resultado=Label( text="Resultado Total",font=("Arial","11","bold"))
resultado.place(relx=0.7,rely=0.3)
resultadof=Label( textvariable=custototal)
resultadof.place(relx=0.72,rely=0.35,relwidth=0.2)
root.config(bg='firebrick4')
root.mainloop()
Comentários
Enviar um comentário