#Fórmula da lei de Ohm: tensão = corrente * resistência
from tkinter import *
root = Tk()
root.geometry("500x400")
root.resizable(0, 0)
root.config(bg="#32a4a8")
root.title("Lei de Ohm-tensão ")
def limpar():
Resistência_entrada.delete(0, END)
Corrente_entrada.delete(0, END)
def app():
c = Corrente.get()
r = Resistência.get()
tensão = c*r
mensagem = f"{tensão} volts"
resultado.set(mensagem)
titulo = Label(text="Lei de Ohm",
font=("Arial", "25", "bold"),bg="#32a4a8",fg="#a8328c")
titulo.place(relx=0.35, rely=0.05)
texto_sub1 = Label(text="Corrente (medida em amperes):",
font=("Arial", "15", "bold"),bg="#32a4a8",fg="#a8328c")
texto_sub1.place(relx=0.05, rely=0.25)
texto_sub2 = Label(text="Resistência Elétrica (Ω):",
font=("Arial", "15", "bold"),bg="#32a4a8",fg="#a8328c")
texto_sub2.place(relx=0.18, rely=0.4)
Corrente = DoubleVar()
Corrente_entrada = Entry(textvariable=Corrente,font=("Arial", "12", "bold")
,bg="white", fg="blue", justify='center')
Corrente_entrada.place(relx=0.68, rely=0.25, relwidth=0.25)
Resistência = DoubleVar()
Resistência_entrada = Entry(textvariable=Resistência,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Resistência_entrada.place(relx=0.68, 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.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.1)
root.mainloop()