from tkinter import *
root = Tk()
root.title("Pagamento do Empréstimo Amortizado")
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#d9ead3")
def app():
r = taxa_juro.get()
rp = r/100
m = valor_emprestado.get()
p = Número_Pagamentos.get()
a = pow((1+rp),-p)
d = 1-a
s = m/d
sarr = round(s,3)
resultado.set(sarr)
def limpar():
valor_emprestado_entrada.delete(0, END)
taxa_juro_entrada.delete(0, END)
Número_Pagamentos_entrada.delete(0, END)
titulo = Label(text="Pagamento do Empréstimo Amortizado",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
titulo.place(relx=0.1, rely=0.05)
texto_sub1= Label(text="Valor emprestado:",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub1.place(relx=0.15, rely=0.2)
texto_sub2= Label(text="Taxa de Juro:",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub2.place(relx=0.23, rely=0.3)
texto_sub3= Label(text="Número de Pagamentos:",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub3.place(relx=0.05, rely=0.4)
taxa_juro = DoubleVar()
taxa_juro_entrada = Entry(textvariable=taxa_juro,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
taxa_juro_entrada.place(relx=0.55, rely=0.3, relwidth=0.25)
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.2, relwidth=0.25)
Número_Pagamentos = IntVar()
Número_Pagamentos_entrada = Entry(textvariable=Número_Pagamentos,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Número_Pagamentos_entrada.place(relx=0.55, rely=0.4, relwidth=0.25)
but1 = Button(text="Calculadora", bd=2, bg='#107db2', fg='white',
font=('verdana', 10, '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', 10, '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', 10, 'bold'), command=root.destroy)
but_sair.place(relx=0.65, rely=0.55, relwidth=0.25, relheight=0.1)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"),bg="#d9ead3" )
resultado_texto.place(relx=0.5, rely=0.75, relwidth=0.3,relheight=0.08)
texto_sub3= Label(text=f"Empréstimo Amortizado:",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub3.place(relx=0.05, rely=0.75)
root.mainloop()