from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#2a508c")
root.title("Taxa de Crescimento Sustentável")
titulo = Label(text="Taxa de Crescimento Sustentável",
font=("Arial", "18", "bold"),bg="#2a508c",fg="#04bfcc")
titulo.place(relx=0.04, rely=0.05)
texto_sub1 = Label(text="Retenção de Lucros:",
font=("Arial", "14", "bold"),bg="#2a508c",fg="#04bfcc")
texto_sub1.place(relx=0.05, rely=0.25)
texto_sub2 = Label(text="ROE:",
font=("Arial", "14", "bold"),bg="#2a508c",fg="#04bfcc")
texto_sub2.place(relx=0.4, rely=0.4)
Retenção_Lucros = DoubleVar()
Retenção_Lucros_entrada = Entry(textvariable=Retenção_Lucros,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Retenção_Lucros_entrada.place(relx=0.55, rely=0.25, relwidth=0.35)
ROE = DoubleVar()
ROE_entrada = Entry(textvariable=ROE,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
ROE_entrada.place(relx=0.55, rely=0.4, relwidth=0.35)
def app():
lucros = Retenção_Lucros.get()
roe = ROE.get()
d = lucros*roe
D = 1-d
TCS = d/D
mensagem = f"Taxa de Crescimento Sustentável: {round(TCS,2)}"
resultado.set(mensagem)
def limpar():
ROE_entrada.delete(0, END)
Retenção_Lucros_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.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.7, relwidth=0.9,relheight=0.28)
root.mainloop()