from tkinter import *
import tkinter as tk
root = Tk()
root.geometry("580x550")
root.resizable(0, 0)
root.config(bg="#114557")
root.title("Taxa Metabólica Basal (TMB)")
titulo = Label(text="Taxa Metabólica Basal (TMB)",
font=("Arial", "30", "bold"),bg="#114557",fg="#d3e7ed")
titulo.place(relx=0.03, rely=0.05)
texto_sub1 = Label(text="Idade :",
font=("Arial", "18", "bold"),bg="#114557",fg="#d3e7ed")
texto_sub1.place(relx=0.34, rely=0.2)
texto_sub2 = Label(text="Altura (em cm) :",
font=("Arial", "18", "bold"),bg="#114557",fg="#d3e7ed")
texto_sub2.place(relx=0.15, rely=0.3)
texto_sub3 = Label(text="Peso (em kg) :",
font=("Arial", "18", "bold"),bg="#114557",fg="#d3e7ed")
texto_sub3.place(relx=0.15, rely=0.4)
idade = IntVar()
idade_entrada = Entry(textvariable=idade,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
idade_entrada.place(relx=0.5, rely=0.2, relwidth=0.25)
altura = DoubleVar()
altura_entrada = Entry(textvariable=altura,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
altura_entrada.place(relx=0.5, rely=0.3, relwidth=0.25)
peso = DoubleVar()
peso_entrada = Entry(textvariable=peso,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
peso_entrada.place(relx=0.5, rely=0.4, relwidth=0.25)
sexo = StringVar()
mas_radio = tk.Radiobutton(root,
text="Masculino",
padx=20,
variable=sexo,
value='m',font=("Arial", "15", "bold"))
mas_radio.place(relx=0.15,rely=0.5)
fem_radio = tk.Radiobutton(root,
text="Feminino",
padx=20,
variable=sexo,
value='f',font=("Arial", "15", "bold"))
fem_radio.place(relx=0.55,rely=0.5)
def limpar():
altura_entrada.delete(0, END)
idade_entrada.delete(0, END)
peso_entrada.delete(0, END)
resultado.set("")
def app():
i = idade.get()
altura_cm = altura.get()
peso_kg = peso.get()
sexo_valor = sexo.get()
if sexo == 'm':
sexo_valor = 88.362 + (13.397 * peso_kg) + (4.799 * altura_cm) - (5.677 * i)
else:
tmb = 447.593 + (9.247 * peso_kg) + (3.098 * altura_cm) - (4.330 * i)
tmbarr = round(tmb,2)
mensagem = f"Sua Taxa Metabólica Basal (TMB) é de aproximadamente\n{tmbarr} calorias por dia."
resultado.set(mensagem)
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()