from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#144996")
root.title("Calcular o Pagamento Periódico ")
titulo = Label(text="Calcular o Pagamento Periódico",
font=("Arial", "18", "bold"),bg="#144996",fg="#c8d5e8")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(text="Montante do Empréstimo:",
font=("Arial", "15", "bold"),bg="#144996",fg="#c8d5e8")
texto_sub1.place(relx=0.05, rely=0.25)
texto_sub2 = Label(text="Número de Períodos:",
font=("Arial", "15", "bold"),bg="#144996",fg="#c8d5e8")
texto_sub2.place(relx=0.15, rely=0.4)
texto_sub3= Label(text="Taxa de Juros (%) :",
font=("Arial", "15", "bold"),bg="#144996",fg="#c8d5e8")
texto_sub3.place(relx=0.18, rely=0.55)
anos = IntVar()
anos_entrada = Entry(textvariable=anos,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
anos_entrada.place(relx=0.68, rely=0.4, relwidth=0.3)
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.68, rely=0.55, relwidth=0.3)
montante = DoubleVar()
montante_entrada = Entry(textvariable=montante,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
montante_entrada.place(relx=0.68, rely=0.25, relwidth=0.3)
def limpar():
montante_entrada.delete(0, END)
taxa_juro_entrada.delete(0, END)
anos_entrada.delete(0, END)
resultado.set("")
def app():
tx_juro = taxa_juro.get()
tx_juropp = tx_juro / 100
m = montante.get()
p = anos.get()
pmt = m * tx_juropp * (1 + tx_juropp) ** p / ((1 + tx_juropp) ** p - 1)
resultadoarr = round(pmt, 2)
resultado.set(resultadoarr)
but1 = Button(text="Calcular", 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="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.85, relwidth=0.9,relheight=0.1)
root.mainloop()