from tkinter import *
import math
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#163f82")
root.title("Fórmula de Amortização de Empréstimo")
titulo = Label(text="Fórmula de Amortização de Empréstimo",
font=("Arial", "15", "bold"), bg="#163f82", fg="#07e4e8")
titulo.place(relx=0.03, rely=0.05)
texto_sub1 = Label(text="Valor do Empréstimo:",
font=("Arial", "12", "bold"), bg="#163f82", fg="#07e4e8")
texto_sub1.place(relx=0.1, rely=0.25)
texto_sub2 = Label(text="Taxa de juros mensal (em %):",
font=("Arial", "12", "bold"), bg="#163f82", fg="#07e4e8")
texto_sub2.place(relx=0.05, rely=0.4)
texto_sub3 = Label(text="Número de meses:",
font=("Arial", "12", "bold"), bg="#163f82", fg="#07e4e8")
texto_sub3.place(relx=0.1, rely=0.55)
Valor_Empréstimo = DoubleVar()
Valor_Empréstimo_entrada = Entry(textvariable=Valor_Empréstimo,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Valor_Empréstimo_entrada.place(relx=0.6, rely=0.25, relwidth=0.3)
taxa_juros_mensal = DoubleVar()
taxa_juros_mensal_entrada = Entry(textvariable=taxa_juros_mensal,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
taxa_juros_mensal_entrada.place(relx=0.63, rely=0.4, relwidth=0.3)
Número_meses = IntVar()
Número_meses_entrada = Entry(textvariable=Número_meses,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Número_meses_entrada.place(relx=0.6, rely=0.55, relwidth=0.3)
def limpar():
Número_meses_entrada.delete(0, END)
taxa_juros_mensal_entrada.delete(0, END)
Valor_Empréstimo_entrada.delete(0, END)
resultado.set("")
def app():
emprestimo = Valor_Empréstimo.get()
tx = taxa_juros_mensal.get() / 100
meses = Número_meses.get()
PMT = (emprestimo * tx) / (1 - math.pow(1 + tx, -meses))
PMTarr = round(PMT, 2)
resultado.set(PMTarr)
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.15)
root.mainloop()