from tkinter import *
root = Tk()
root.geometry("450x300")
root.resizable(0, 0)
root.config(bg="#306b9c")
root.title("Calcular altura da queda")
titulo = Label(text="Calcular altura da queda",
font=("Arial", "26", "bold"),bg="#306b9c",fg="#bdccd9")
titulo.place(relx=0.05, rely=0.05)
texto_sub1= Label(text="Tempo (em segundos): ",
font=("Arial", "15", "bold"),bg="#306b9c",fg="#bdccd9")
texto_sub1.place(relx=0.05, rely=0.3)
tempo = IntVar()
tempo_entrada = Entry(textvariable=tempo,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
tempo_entrada.place(relx=0.6, rely=0.3, relwidth=0.35)
def limpar():
tempo_entrada.delete(0, END)
resultado.set("")
def app():
t = tempo.get()
g = 9.81
altura = 0.5 * g * (t ** 2)
alturaarr = round(altura,2)
mensagem = f"A Altura da queda é de: {alturaarr} metros."
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.5, relwidth=0.25, relheight=0.15)
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.5, relwidth=0.25, relheight=0.15)
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.5, relwidth=0.25, relheight=0.15)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.7, relwidth=0.9,relheight=0.25)
root.mainloop()
Comentários
Enviar um comentário