Mundo em Python

Rendimento de Investimento

from tkinter import *
root = Tk()
root.geometry("800x500")
root.resizable(0, 0)
root.config(bg="#d9ead3")
root.title("Rendimento de Investimento")
def limpar():
Valor_Inicial_entrada.delete(0,END)
Taxa_Juros_entrada.delete(0, END)
Período_entrada.delete(0, END)
def app():
p =Período.get()
tx = Taxa_Juros.get()
vi = Valor_Inicial.get()
valor_final = vi * (1 + tx / 100) ** p
rendimento = valor_final - vi
rendimentoarr = round(rendimento,2)
mensagem = f"O rendimento do investimento será: {rendimentoarr}€"
resultado.set(mensagem) titulo = Label(text="Rendimento de Investimento",
font=("Arial", "19", "bold"),bg="#d9ead3",fg="#bf9000")
titulo.place(relx=0.35, rely=0.05)
texto_sub1 = Label(text="Valor Inicial:",
font=("Arial", "15", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub1.place(relx=0.3, rely=0.2)
texto_sub2= Label(text="Taxa Juros(%):",
font=("Arial", "15", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub2.place(relx=0.3, rely=0.35) texto_sub3= Label(text="Período:",
font=("Arial", "15", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub3.place(relx=0.35, 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.5, rely=0.2, relwidth=0.3) Taxa_Juros = DoubleVar()
Taxa_Juros_entrada = Entry(textvariable=Taxa_Juros,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Taxa_Juros_entrada.place(relx=0.5, rely=0.35, relwidth=0.3) Período = IntVar()
Período_entrada = Entry(textvariable=Período,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Período_entrada.place(relx=0.5, rely=0.5, 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.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.1)
root.mainloop()
0