from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#d9ead3")
root.title("Margem de Lucro ")
def limpar():
Lucro_Líquido_entrada.delete(0, END)
Receita_Total_entrada.delete(0, END)
def app():
luc_liq = Lucro_Líquido.get()
rec_tot = Receita_Total.get()
# Margem de Lucro = (Lucro Líquido / Receita Total) * 100
Margem_Lucro = (luc_liq/rec_tot)*100
Margem_Lucroarr = round(Margem_Lucro,2)
resultado.set(Margem_Lucroarr)
titulo = Label(text="Margem de Lucro",
font=("Arial", "25", "bold"),bg="#d9ead3",fg="#bf9000")
titulo.place(relx=0.15, rely=0.05)
texto_sub1 = Label(text="Lucro Líquido:",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub1.place(relx=0.15, rely=0.25)
texto_sub2 = Label(text="Receita Total:",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub2.place(relx=0.15, rely=0.4)
Lucro_Líquido = DoubleVar()
Lucro_Líquido_entrada = Entry(textvariable=Lucro_Líquido,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Lucro_Líquido_entrada.place(relx=0.5, rely=0.25, relwidth=0.35)
Receita_Total = DoubleVar()
Receita_Total_entrada = Entry(textvariable=Receita_Total,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Receita_Total_entrada.place(relx=0.5, rely=0.4, relwidth=0.35)
#
but1 = Button(text="Verificar", 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)
texto_sub3 = Label(text="Margem de Lucro(%):",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub3.place(relx=0.1, rely=0.83)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#d9ead3")
resultado_texto.place(relx=0.55, rely=0.8, relwidth=0.25,relheight=0.1)
root.mainloop()