Mundo em Python

Taxa de Rentabilidade Total

from tkinter import *
root = Tk()
root.geometry("400x500")
root.resizable(0, 0)
root.config(bg="#114469")
root.title("Taxa de rentabilidade Total (TRT)")
titulo = Label(text="Taxa de Rentabilidade Total",
font=("Arial", "20", "bold"),bg="#114469",fg="#19e6d1")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(text="Custo Total: ",
font=("Arial", "15", "bold"),bg="#114469",fg="#19e6d1")
texto_sub1.place(relx=0.2, rely=0.2) texto_sub2 = Label(text="Valor Emprestado:",
font=("Arial", "15", "bold"),bg="#114469",fg="#19e6d1")
texto_sub2.place(relx=0.05, rely=0.35)
texto_sub3 = Label(text="Valor Final:",
font=("Arial", "15", "bold"),bg="#114469",fg="#19e6d1")
texto_sub3.place(relx=0.2, rely=0.5) Custo_Total = DoubleVar()
Custo_Total_entrada = Entry(textvariable=Custo_Total,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Custo_Total_entrada.place(relx=0.55, rely=0.2, relwidth=0.35)
Valor_Emprestado = DoubleVar()
Valor_Emprestado_entrada = Entry(textvariable=Valor_Emprestado,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Valor_Emprestado_entrada.place(relx=0.55, rely=0.35, relwidth=0.35) Valor_Final = DoubleVar()
Valor_Final_entrada = Entry(textvariable=Valor_Final,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Valor_Final_entrada.place(relx=0.55, rely=0.5, relwidth=0.35)
def limpar():
Valor_Final_entrada.delete(0, END)
Valor_Emprestado_entrada.delete(0, END)
Custo_Total_entrada.delete(0, END)
resultado.set("")
def app():
vf = Valor_Final.get()
ve = Valor_Emprestado.get()
ct = Custo_Total.get()
TRT = (vf - ct) / ve * 100
if TRT <=5:
classicacao = "Muito Baixa"
elif TRT <=10:
classicacao = "Baixa"
elif TRT <=15:
classicacao = "Média"
elif TRT <=20:
classicacao = "Alta"
else:
classicacao = "Muito Alta"

mensagem = f"Taxa de Rentabilidade Total (TRT):{round(TRT,2)} %\n Classificação: {classicacao}"
resultado.set(mensagem)
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, 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.35, 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.65, rely=0.65, 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