from tkinter import *
root= Tk()
root.geometry("400x550")
root.resizable(0, 0)
root.config(bg="#335182")
root.title("Taxa de Juro")
titulo = Label(text="Taxa de Juro",
font=("Arial", "35", "bold"),bg="#335182",fg="#14bcf5")
titulo.place(relx=0.15, rely=0.05)
texto_sub1 = Label(text="Valor Presente:",
font=("Arial", "18", "bold"),bg="#335182",fg="#14bcf5")
texto_sub1.place(relx=0.1, rely=0.2)
texto_sub2= Label(text="Valor Futuro:",
font=("Arial", "18", "bold"),bg="#335182",fg="#14bcf5")
texto_sub2.place(relx=0.12, rely=0.35)
texto_sub3= Label(text="Tempo (em anos):",
font=("Arial", "18", "bold"),bg="#335182",fg="#14bcf5")
texto_sub3.place(relx=0.03, rely=0.5)
valor_presente = DoubleVar()
valor_presente_entrada = Entry(textvariable=valor_presente,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
valor_presente_entrada.place(relx=0.6, rely=0.2, relwidth=0.3)
valor_futuro = DoubleVar()
valor_futuro_entrada = Entry(textvariable=valor_futuro,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
valor_futuro_entrada.place(relx=0.6, rely=0.35, relwidth=0.3)
tempo = IntVar()
tempo_entrada = Entry(textvariable=tempo,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
tempo_entrada.place(relx=0.6, rely=0.51, relwidth=0.3)
def limpar():
valor_presente_entrada.delete(0, END)
valor_futuro_entrada.delete(0, END)
tempo_entrada.delete(0, END)
resultado.set("")
def app():
vp = valor_presente.get()
vf = valor_futuro.get()
t = tempo.get()
taxa = ((vf / vp) ** (1 / t)) - 1
taxaarr = round(taxa*100,2)
mensagem = f"A taxa de juro é de {taxaarr} %."
resultado.set(mensagem)
but1 = Button(text="Verificar", 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()