from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#166273")
root.title("Contagem de Calorias")
titulo = Label(text="Contagem de Calorias",
font=("Arial", "26", "bold"),bg="#166273",fg="#1eebd6")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(text="Pequeno-Almoço:",
font=("Arial", "15", "bold"),bg="#166273",fg="#1eebd6")
texto_sub1.place(relx=0.1, rely=0.23)
texto_sub2 = Label(text="Almoço:",
font=("Arial", "15", "bold"),bg="#166273",fg="#1eebd6")
texto_sub2.place(relx=0.3, rely=0.35)
texto_sub3 = Label(text="Lance:",
font=("Arial", "15", "bold"),bg="#166273",fg="#1eebd6")
texto_sub3.place(relx=0.33, rely=0.45)
texto_sub4 = Label(text="Jantar:",
font=("Arial", "15", "bold"),bg="#166273",fg="#1eebd6")
texto_sub4.place(relx=0.35, rely=0.55)
Pequeno_Almoço = IntVar()
Pequeno_Almoço_entrada = Entry(textvariable=Pequeno_Almoço,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Pequeno_Almoço_entrada.place(relx=0.55, rely=0.23, relwidth=0.35)
Almoço = IntVar()
Almoço_entrada = Entry(textvariable=Almoço,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Almoço_entrada.place(relx=0.55, rely=0.35, relwidth=0.35)
Lance = IntVar()
Lance_entrada = Entry(textvariable=Lance,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Lance_entrada.place(relx=0.55, rely=0.45, relwidth=0.35)
Jantar = IntVar()
Jantar_entrada = Entry(textvariable=Jantar,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Jantar_entrada.place(relx=0.55, rely=0.55, relwidth=0.35)
def app():
ja=Jantar.get()
al =Almoço.get()
peq =Pequeno_Almoço.get()
lan = Lance.get()
cal = ja+al+peq+lan
mensagem= f"Total de calorias: {cal}"
resultado.set(mensagem)
def limpar():
Jantar_entrada.delete(0, END)
Almoço_entrada.delete(0, END)
Lance_entrada.delete(0, END)
Pequeno_Almoço_entrada.delete(0, END)
resultado.set("")
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, rely=0.65, relwidth=0.25, relheight=0.1)
but_limpar = Button(text="Limpar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=limpar)
but_limpar.place(relx=0.35, rely=0.65, relwidth=0.25, relheight=0.1)
but_sair = Button(text="Sair", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=root.destroy)
but_sair.place(relx=0.65, rely=0.65, relwidth=0.25, relheight=0.1)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9,relheight=0.15)
root.mainloop()