Calcular a Distância da Trovoada

from tkinter import *
root = Tk()
def limpar():
tempo_entrada.delete(0, END)
resultado.set("")
def app():
t = tempo.get()
velocidade_som = 343
distance = velocidade_som * t
mensagem = f"A distância aproximada da trovoada é de {distance} metros."
resultado.set(mensagem)
root.geometry("600x300")
root.resizable(0, 0)
root.config(bg="#d9ead3")
root.title("Calcular a Distância da Trovoada ")
titulo = Label(text="Calcular a Distância da Trovoada",
font=("Arial", "25", "bold"),bg="#d9ead3",fg="#bf9000")
titulo.place(relx=0.08, rely=0.05)
texto_sub1 = Label(text="Tempo entre o relâmpago e o som(em segundos):",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub1.place(relx=0.03, rely=0.4)

tempo = IntVar()
tempo_entrada = Entry(textvariable=tempo,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
tempo_entrada.place(relx=0.7, rely=0.4, relwidth=0.25)


#
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, rely=0.6, 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.6, 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.6, 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.8, relwidth=0.9,relheight=0.15)
root.mainloop()

Comentários

Mensagens populares deste blogue

Criar Cartões de Visita

12 signos egípcios

Calcular a percentagem de ocupação