from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Converter Nota")
titulo = Label(text="Converter Nota",
font=("Arial", "28", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.13, rely=0.05)
texto_sub1 = Label(text="Nota (de 0-100) : ",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.1, rely=0.32)
Nota = StringVar()
Nota_entrada = Entry(textvariable=Nota,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Nota_entrada.place(relx=0.6, rely=0.33, relwidth=0.3)
def limpar():
Nota_entrada.delete(0, END)
resultado_texto.config(text="")
def app():
try:
n = int(Nota.get())
if n < 0 or n > 100:
mensagem = "A nota deve estar entre 0 e 100!"
elif n >= 90:
mensagem = f"A nota {n} é convertida em A."
elif n >= 80:
mensagem = f"A nota {n} é convertida em B."
elif n >= 70:
mensagem = f"A nota {n} é convertida em C."
elif n >= 60:
mensagem = f"A nota {n} é convertida em D."
else:
mensagem = f"A nota {n} é convertida em F."
resultado_texto.config(text=mensagem)
except ValueError:
resultado_texto.config(text="Por favor, insira um número válido!")
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, 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.4, 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.7, rely=0.65, 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()
Comentários
Enviar um comentário