Mundo em Python

Ângulo de Brewster

from tkinter import *
import math
root = Tk()
root.geometry("700x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Ângulo de Brewster")
titulo = Label(text="Ângulo de Brewster",
font=("Arial", "28", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.25, rely=0.05) texto_sub1 = Label(text="índice de refração do primeiro meio:",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.05, rely=0.32) texto_sub2 = Label(text="índice de refração do segundo meio:",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub2.place(relx=0.05, rely=0.52)
n1 = StringVar()
n1_entrada = Entry(textvariable=n1,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
n1_entrada.place(relx=0.67, rely=0.32, relwidth=0.23)
n1_entrada.focus() n2 = StringVar()
n2_entrada = Entry(textvariable=n2,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
n2_entrada.place(relx=0.67, rely=0.53, relwidth=0.23) def limpar():
n1_entrada.delete(0, END)
n2_entrada.delete(0, END)
resultado_texto.config(text="")
def app():
N1 =float(n1.get())
N2 =float( n2.get())
angulo_rad = math.atan(N2 / N1)
angulo_graus = math.degrees(angulo_rad)
mensagem =f"O Ângulo de Brewster é: {angulo_graus:.2f} graus."
resultado_texto.config(text=mensagem)
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.65, 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.4, rely=0.65, 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.7, rely=0.65, relwidth=0.25, relheight=0.1)
resultado_texto = Label(text="",
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9, relheight=0.15)
root.mainloop()
0