from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#0d7570")
root.title("Return on Invested Capital")
titulo = Label(text="Return on Invested Capital",
font=("Arial", "20", "bold"),bg="#0d7570",fg="#4ae8e0")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(text="Lucro Operacional:",
font=("Arial", "15", "bold"),bg="#0d7570",fg="#4ae8e0")
texto_sub1.place(relx=0.15, rely=0.25)
texto_sub2 = Label(text="Capital Investido:",
font=("Arial", "15", "bold"),bg="#0d7570",fg="#4ae8e0")
texto_sub2.place(relx=0.18, rely=0.45)
Capital_Investido = DoubleVar()
Capital_Investido_entrada = Entry(textvariable=Capital_Investido,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Capital_Investido_entrada.place(relx=0.65, rely=0.45, relwidth=0.28)
Lucro_Operacional = DoubleVar()
Lucro_Operacional_entrada = Entry(textvariable=Lucro_Operacional,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Lucro_Operacional_entrada.place(relx=0.65, rely=0.25, relwidth=0.28)
def limpar():
Lucro_Operacional_entrada.delete(0, END)
Capital_Investido_entrada.delete(0, END)
resultado.set("")
def app():
try:
ci = float(Capital_Investido.get())
lucro = float(Lucro_Operacional.get())
ROIC = (lucro / ci) * 100
mensagem = f"Return on Invested Capital: {round(ROIC, 2)}"
resultado.set(mensagem)
except ValueError:
resultado.set("Por favor, insira valores numéricos.")
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, rely=0.6, 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.6, 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.6, 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.15)
root.mainloop()