Simulador investimentos

from tkinter import *
root = Tk()
root.geometry("500x450")
root.resizable(0, 0)
root.config(bg="#aed5f5")
root.title("Simulador investimentos")

def limpar():
tx_juro_entrada.delete(0, END)
Valor_inicial_entrada.delete(0, END)
tempo_entrada.delete(0, END)
contribuicao_entrada.delete(0, END)

def app():
v_inicial = Valor_inicial.get()
juro = tx_juro.get()
juropp = juro / 100
prazo = tempo.get()
c = contribuicao.get()
saldo = v_inicial
for mes in range(prazo * 12):
saldo = c+saldo
saldo = saldo* (1 + juropp / 12)
saldoarr = round(saldo,2)
mensagem = f'O saldo final do investimento será: {saldoarr} €'
resultado.set(mensagem)
titulo = Label(text="Simulador investimentos",
font=("Arial", "23", "bold"),bg="#aed5f5",fg="#bf9000")
titulo.place(relx=0.15, rely=0.05)
texto_sub1 = Label(text="Valor Inicial:",
font=("Arial", "15", "bold"),bg="#aed5f5",fg="#bf9000")
texto_sub1.place(relx=0.28, rely=0.25)

texto_sub2= Label(text="Taxa de juros anual(em %):",
font=("Arial", "15", "bold"),bg="#aed5f5",fg="#bf9000")
texto_sub2.place(relx=0.02, rely=0.4)

texto_sub3= Label(text="Tempo (em anos): ",
font=("Arial", "15", "bold"),bg="#aed5f5",fg="#bf9000")
texto_sub3.place(relx=0.15, rely=0.6)

texto_sub4= Label(text="Contribuição mensal: ",
font=("Arial", "15", "bold"),bg="#aed5f5",fg="#bf9000")
texto_sub4.place(relx=0.12, rely=0.5)

Valor_inicial = DoubleVar()
Valor_inicial_entrada = Entry(textvariable=Valor_inicial,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Valor_inicial_entrada.place(relx=0.55, rely=0.25, relwidth=0.35)

tx_juro = DoubleVar()
tx_juro_entrada = Entry(textvariable=tx_juro,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
tx_juro_entrada.place(relx=0.55, rely=0.4, relwidth=0.35)
contribuicao = DoubleVar()
contribuicao_entrada = Entry(textvariable=contribuicao,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
contribuicao_entrada.place(relx=0.55, rely=0.5, relwidth=0.35)

tempo = IntVar()
tempo_entrada = Entry(textvariable=tempo,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
tempo_entrada.place(relx=0.55, rely=0.6, 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.7, 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.7, 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.7, relwidth=0.25, relheight=0.1)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#5fc2ba")
resultado_texto.place(relx=0.05, rely=0.85, relwidth=0.9,relheight=0.1)
root.mainloop()

Comentários

Mensagens populares deste blogue

Criar Cartões de Visita

12 signos egípcios

Calcular a percentagem de ocupação