import math
from tkinter import *
root = Tk()
root.geometry("400x250")
root.resizable(0, 0)
root.config(bg="#0a73a1")
root.title("Calcular Velocidade Queda")
titulo = Label(text="Calcular Velocidade Queda",
font=("Arial", "20", "bold"),bg="#0a73a1",fg="#ebf3f5")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(text="Altura da Queda (em metros) :",
font=("Arial", "12", "bold"),bg="#0a73a1",fg="#ebf3f5")
texto_sub1.place(relx=0.05, rely=0.35)
Altura_Queda = DoubleVar()
Altura_Queda_entrada = Entry(textvariable=Altura_Queda,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Altura_Queda_entrada.place(relx=0.65, rely=0.35, relwidth=0.25)
def limpar():
Altura_Queda_entrada.delete(0, END)
resultado.set("")
def app():
g =9.8
a = Altura_Queda.get()
v = math.sqrt(2 * g * a)
varr = round(v,2)
mensagem = f'A velocidade de queda é de {varr} m/s'
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.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.35, 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.65, rely=0.55, relwidth=0.25, relheight=0.1)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.75, relwidth=0.9,relheight=0.15)
root.mainloop()
Comentários
Enviar um comentário