from tkinter import *
root = Tk()
root.geometry("500x400")
root.resizable(0, 0)
root.config(bg="#d9ead3")
root.title("Índice de lucratividade ")
def limpar():
val_entrada.delete(0, END)
Investimento_Inicial_entrada.delete(0, END)
def app():
val_variavel = val.get()
Investimento_Inicial_variavel = Investimento_Inicial.get()
Índice_Lucratividade = (val_variavel/Investimento_Inicial_variavel)
Índice_Lucratividadeaar = round(Índice_Lucratividade,2)
if Índice_Lucratividadeaar>1:
mansagem = f"O Índice Lucratividade é de {Índice_Lucratividadeaar}.\n" \
f" O que significa que o projeto é considerado lucrativo."
elif Índice_Lucratividadeaar ==1:
mansagem = f"O Índice Lucratividade é de {Índice_Lucratividadeaar}.\n" \
f" O que significa que o projecto\n considerado neutro em termos de lucratividade,\n" \
f" pois não há ganhos ou perdas adicionais."
else:
mansagem = f"O Índice Lucratividade é de {Índice_Lucratividadeaar}.\n" \
f" O que significa que o projeto pode não ser viável\ndo ponto de vista financeiro."
resultado.set(mansagem)
titulo = Label(text="Índice de Lucratividade",
font=("Arial", "25", "bold"),bg="#d9ead3",fg="#bf9000")
titulo.place(relx=0.06, rely=0.05)
texto_sub1 = Label(text="Valor Actual Líquido :",
font=("Arial", "15", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub1.place(relx=0.05, rely=0.3)
texto_sub2= Label(text="Investimento Inicial :",
font=("Arial", "15", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub2.place(relx=0.08, rely=0.45)
val = DoubleVar()
val_entrada = Entry(textvariable=val,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
val_entrada.place(relx=0.63, rely=0.3, relwidth=0.3)
Investimento_Inicial = DoubleVar()
Investimento_Inicial_entrada = Entry(textvariable=Investimento_Inicial,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Investimento_Inicial_entrada.place(relx=0.63, rely=0.45, relwidth=0.3)
#
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_sub2= Label(text="Investimento Inicial :",
font=("Arial", "15", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub2.place(relx=0.08, rely=0.45)
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.2)
root.mainloop()