Mundo em Python

Fluxo Magnético

from tkinter import *
import math
root = Tk()
root.geometry("700x500")
root.resizable(0, 0)
root.config(bg="#0f637a")
root.title("Fluxo Magnético ")
titulo = Label(text="Fluxo Magnético",
font=("Arial", "60", "bold"),bg="#0f637a",fg="#66d0ed")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(text="Intensidade do campo magnético(em teslas):",
font=("Arial", "15", "bold"),bg="#0f637a",fg="#66d0ed")
texto_sub1.place(relx=0.05, rely=0.3)
texto_sub2 = Label(text="Área da Superfície: ",
font=("Arial", "15", "bold"),bg="#0f637a",fg="#66d0ed")
texto_sub2.place(relx=0.4, rely=0.45) texto_sub3 = Label(text="Ângulo entre o vetor campo magnético: ",
font=("Arial", "15", "bold"),bg="#0f637a",fg="#66d0ed")
texto_sub3.place(relx=0.13, rely=0.6)
teslas = DoubleVar()
teslas_entrada = Entry(textvariable=teslas,font=("Arial", "12", "bold")
,bg="white", fg="blue", justify='center')
teslas_entrada.place(relx=0.7, rely=0.3, relwidth=0.25) área_superfície = DoubleVar()
área_superfície_entrada = Entry(textvariable=área_superfície,font=("Arial", "12", "bold")
,bg="white", fg="blue", justify='center')
área_superfície_entrada.place(relx=0.7, rely=0.45, relwidth=0.25) campo_magnético = DoubleVar()
campo_magnético_entrada = Entry(textvariable=campo_magnético,font=("Arial", "12", "bold")
,bg="white", fg="blue", justify='center')
campo_magnético_entrada.place(relx=0.7, rely=0.6, relwidth=0.25)
def app():
angulo = float(campo_magnético.get())
A = área_superfície.get()
B = teslas.get()
Φ = B * A * math.cos(angulo)
mensagem = f"O fluxo magnético é de {round(Φ,2)}."
resultado.set(mensagem) def limpar():
campo_magnético_entrada.delete(0, END)
área_superfície_entrada.delete(0, END)
teslas_entrada.delete(0, END)
resultado.set("") but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, rely=0.68, 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.68, 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.68, 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()
0