Mundo em Python

Votos por sócio do Benfica

from tkinter import *

root = Tk()
root.geometry("700x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Votos por sócio") titulo = Label(text="Votos por sócio",
font=("Arial", "28", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.25, rely=0.05) texto_sub1 = Label(text="Anos de Sócios:",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.2, rely=0.32) Anos_Sócios = StringVar()
Anos_Sócios_entrada = Entry(textvariable=Anos_Sócios,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Anos_Sócios_entrada.place(relx=0.55, rely=0.33, relwidth=0.35) Anos_Sócios_entrada.focus() def limpar():
resultado_texto.config(text="")
Anos_Sócios.set("")
Anos_Sócios_entrada.focus() def app():
try:
ano = int(Anos_Sócios.get())
except ValueError:
resultado_texto.config(text="⚠️ Digite um número válido.")
return

if ano < 1:
mensagem = "0"
elif 1 <= ano < 5:
mensagem = "1"
elif 5 <= ano < 10:
mensagem = "5"
elif 10 <= ano < 25:
mensagem = "25"
else:
mensagem = "50"

resultado_texto.config(
text=f"O número de votos que tem direito é de {mensagem} voto(s)"
) but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.55, 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.55, 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.55, relwidth=0.25, relheight=0.1) resultado_texto = Label(text="",
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9, relheight=0.15) root.bind("<Return>", lambda event: app()) root.mainloop()
0