Mundo em Python

Classificação categorias de idade de Judo

from tkinter import *
from datetime import date
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Classificação categorias de idade de Judo")
titulo = Label(text="Classificação de idade",
font=("Arial", "25", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.05, rely=0.05) sub1 = Label(text="Ano de Nascimento: ", font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
sub1.place(relx=0.05, rely=0.25)
ano_nascimento = StringVar()
ano_nascimento_entrada = Entry(textvariable=ano_nascimento, font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
ano_nascimento_entrada.place(relx=0.57, rely=0.26, relwidth=0.38)
ano_nascimento_entrada.focus()
def limpar():
ano_nascimento_entrada.delete(0, END)
resultado_texto.config(text="") def app():
try:
ano = int(ano_nascimento.get())
current_date = date.today()
data_atual = current_date.year # Corrigindo o nome da variável
idade = data_atual - ano
if idade < 8:
mensagem = "Ainda não pode competir."
elif idade < 12:
classificacao = "Infantil"
elif idade < 16:
classificacao = "Juvenil"
elif idade < 17:
classificacao = "Cadetes"
elif idade < 22:
classificacao = "Junior"
elif idade < 30:
classificacao = "Sénior"
else:
classificacao = "Veterano"
mensagem = f"Classificação etária: {classificacao}"
resultado_texto.config(text=mensagem)
except ValueError:
resultado_texto.config(text="Erro de digitação!")
but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.4, 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.4, rely=0.4, 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.7, rely=0.4, relwidth=0.25, relheight=0.1) resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.08, rely=0.7, relwidth=0.9, relheight=0.25)
root.mainloop()
0