from tkinter import *
root = Tk()
root.geometry("700x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Classificar o nível do cortisol")
# Título
titulo = Label(
text="Classificar o nível do Cortisol",
font=("Arial", 28, "bold"),
bg="#103030",
fg="#49e3e3"
)
titulo.place(relx=0.13, rely=0.05)
# Texto
texto_sub1 = Label(
text="Valor de cortisol (µg/dL):",
font=("Arial", 18, "bold"),
bg="#103030",
fg="#49e3e3"
)
texto_sub1.place(relx=0.12, rely=0.32)
# Entrada
Valor_cortisol = StringVar()
Valor_cortisol_entrada = Entry(
textvariable=Valor_cortisol,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
Valor_cortisol_entrada.place(relx=0.55, rely=0.33, relwidth=0.35)
Valor_cortisol_entrada.focus()
# Opção (Manhã / Noite)
opcao = StringVar(value="manha")
# Função principal
def app():
try:
periodo = opcao.get()
valor = float(Valor_cortisol.get())
if periodo == "manha":
if valor < 5:
mensagem = "Baixo"
cor = "orange"
elif 5 <= valor <= 25:
mensagem = "Normal"
cor = "green"
else:
mensagem = "Alto"
cor = "red"
elif periodo == "noite":
if valor < 2:
mensagem = "Baixo"
cor = "orange"
elif 2 <= valor <= 9:
mensagem = "Normal"
cor = "green"
else:
mensagem = "Alto"
cor = "red"
resultado_texto.config(
text=f"Classificação: {mensagem}",
bg=cor,
fg="white"
)
except ValueError:
resultado_texto.config(
text="Digite um valor válido!",
bg="gray",
fg="white"
)
# Botão
botao = Button(
text="Classificar",
command=app,
font=("Arial", 14, "bold"),
bg="#49e3e3"
)
botao.place(relx=0.4, rely=0.54)
# Radio buttons
radio1 = Radiobutton(
text="Manhã",
variable=opcao,
value="manha",
font=("Arial", 15, "bold"),
bg="#103030",
fg="white",
selectcolor="#103030"
)
radio1.place(relx=0.25, rely=0.45)
radio2 = Radiobutton(
text="Noite",
variable=opcao,
value="noite",
font=("Arial", 15, "bold"),
bg="#103030",
fg="white",
selectcolor="#103030"
)
radio2.place(relx=0.55, rely=0.45)
# Resultado
resultado_texto = Label(
text="",
font=("Arial", 14, "bold"),
bg="gray",
fg="white"
)
resultado_texto.place(relx=0.05, rely=0.7, relwidth=0.9, relheight=0.25)
root.mainloop()