Mundo em Python

mass–energy equivalence (usando tkinter)

from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#d9ead3")
root.title("mass–energy equivalence")
def app():
m = mass.get()
c = velocidade_luz.get()
e = m *pow(c,2)
resultado.set(e)
def limpar():
mass_entrada.delete(0, END)
velocidade_luz_entrada.delete(0, END)
titulo = Label(text="Mass–Energy Equivalence",
font=("Arial", "15", "bold"),bg="#d9ead3",fg="#bf9000")
titulo.place(relx=0.2, rely=0.05)
texto_sub1 = Label(text="Massa:",
font=("Arial", "12", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub1.place(relx=0.35, rely=0.25)
texto_sub2 = Label(text="Velocidade da luz:",
font=("Arial", "12", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub2.place(relx=0.13, rely=0.4) mass = DoubleVar()
mass_entrada = Entry(textvariable=mass,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
mass_entrada.place(relx=0.55, rely=0.25, relwidth=0.3) velocidade_luz = DoubleVar()
velocidade_luz_entrada = Entry(textvariable=velocidade_luz,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
velocidade_luz_entrada.place(relx=0.55, rely=0.4, relwidth=0.3)
#
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.2, rely=0.55, relwidth=0.2, 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.45, rely=0.55, relwidth=0.2, 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.2, relheight=0.1) resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#55dab8")
resultado_texto.place(relx=0.5, rely=0.75, relwidth=0.3)
escrever_texto = Label(text="Energia",
font=("Arial", 12, "bold"), bg="#d9ead3")
escrever_texto.place(relx=0.2, rely=0.75, relwidth=0.3)
root.mainloop()
0