from tkinter import *
root = Tk()
root.title("Valor de Obrigações")
root.geometry("600x650")
root.resizable(False,False)
root.configure(bg="#c1d5ee")
def limpar1():
taxajuro1_entrada.delete(0, END)
taxajuro2_entrada.delete(0, END)
taxajuro3_entrada.delete(0, END)
pagamentofinal_entrada.delete(0, END)
maturidade_entrada.delete(0, END)
valorcumpo_entrada.delete(0, END)
def butaoclick1():
tx1=v_taxajuro1.get()/100
tx2 = v_taxajuro2.get()/100
tx3 = v_taxajuro3.get()/100
pga = v_pagamentofinal.get()
pa = v_maturidade.get()
cp = v_copum.get()
# Primeiro
cont1 = 1
valor_acumulado1 = 0
while cont1 <= pa:
c1 = pow((1 + tx1), cont1)
valor1 = cp / c1
valor_acumulado1 = valor_acumulado1 + valor1
cont1 = cont1 + 1
t1 = pow((1 + tx1), pa)
final1 = pga / t1
valor_final1 = round((valor_acumulado1 + final1), 2)
mesagem1= f"{valor_final1} "
# Segundo
cont2 = 1
valor_acumulado2 = 0
while cont2 <= pa:
c2 = pow((1 + tx2), cont2)
valor2 = cp / c2
valor_acumulado2 = valor_acumulado2 + valor2
cont2 = cont2 + 1
t2 = pow((1 + tx2), pa)
final2 = pga / t2
valor_final2 = round((valor_acumulado2 + final2), 2)
mesagem2 = f"{valor_final2} "
# Teceiro
cont3 = 1
valor_acumulado3 = 0
while cont3 <= pa:
c3 = pow((1 + tx3), cont3)
valor3 = cp / c3
valor_acumulado3 = valor_acumulado3 + valor3
cont3 = cont3 + 1
t3 = pow((1 + tx3), pa)
final3 = pga / t3
valor_final3 = round((valor_acumulado3 + final3), 2)
mesagem3 = f"{valor_final3}"
exemplo1.set(mesagem1),exemplo2.set(mesagem2),exemplo3.set(mesagem3)
titulo = Label(text="Valor de Obrigações",font=("Arial","15","bold"),
bg="#c1d5ee",fg="red")
titulo.place(relx=0.35,rely=0.05)
taxajuro1 = Label(text="Taxa de Juro",font=("Arial","12","bold"),
bg="#c1d5ee",fg="black")
taxajuro1 .place(relx=0.1,rely=0.15)
taxajuro2 = Label(text="Taxa de Juro",font=("Arial","12","bold"),
bg="#c1d5ee",fg="black")
taxajuro2.place(relx=0.45,rely=0.15)
taxajuro3 = Label(text="Taxa de Juro",font=("Arial","12","bold"),
bg="#c1d5ee",fg="black")
taxajuro3.place(relx=0.75,rely=0.15)
taxajuro3 = Label(text="Taxa de Juro",font=("Arial","12","bold"),
bg="#c1d5ee",fg="black")
taxajuro3.place(relx=0.75,rely=0.15)
pagamentofinal = Label(text="Pagamento Final",font=("Arial","12","bold"),
bg="#c1d5ee",fg="black")
pagamentofinal .place(relx=0.1,rely=0.3)
maturidade = Label(text="Maturidade",font=("Arial","12","bold"),
bg="#c1d5ee",fg="black")
maturidade.place(relx=0.6,rely=0.3)
valorcopum = Label(text="Valor de Copum",font=("Arial","12","bold"),
bg="#c1d5ee",fg="black")
valorcopum.place(relx=0.1,rely=0.4)
v_pagamentofinal = DoubleVar()
v_taxajuro1 = DoubleVar()
v_taxajuro2 = DoubleVar()
v_taxajuro3 = DoubleVar()
v_maturidade = IntVar()
v_copum = DoubleVar()
taxajuro1_entrada = Entry(textvariable=v_taxajuro1,
justify='center',fg="green")
taxajuro1_entrada.place(relx=0.1,rely=0.2)
taxajuro2_entrada = Entry(textvariable=v_taxajuro2
,justify='center',fg="green")
taxajuro2_entrada.place(relx=0.43,rely=0.2)
taxajuro3_entrada = Entry(textvariable=v_taxajuro3,
justify='center',fg="green")
taxajuro3_entrada.place(relx=0.73,rely=0.2)
pagamentofinal_entrada= Entry(textvariable=v_pagamentofinal,
justify='center',fg="green")
pagamentofinal_entrada.place(relx=0.35,rely=0.3)
maturidade_entrada= Entry(textvariable=v_maturidade,
justify='center',fg="green")
maturidade_entrada.place(relx=0.8,rely=0.3,relwidth=0.1)
valorcumpo_entrada= Entry(textvariable=v_copum,
justify='center',fg="green")
valorcumpo_entrada.place(relx=0.35,rely=0.4,relwidth=0.25)
#
bt_calcular1 = Button( text="Calcular", bd=2, bg='#107db2',
fg='white', font=('verdana', 14, 'bold'),
command=butaoclick1)
bt_calcular1.place(relx=0.25,rely=0.5, relwidth=0.2, relheight=0.1)
butlimpar1 = Button( text="Limpar", bd=2,
bg='#107db2', fg='white',
font=('verdana', 14, 'bold'),command=limpar1)
butlimpar1.place(relx=0.6, rely=0.5, relwidth=0.2, relheight=0.1)
exemplo1 = StringVar()
exemplo2 = StringVar()
exemplo3= StringVar()
resultado_exemplo1_texto=Label( text="Exemplo 1",
font=("Arial","12","bold"),bg="#c1d5ee")
resultado_exemplo1_texto.place(relx=0.15,rely=0.7)
resultado_exemplo1=Label( textvariable=exemplo1)
resultado_exemplo1.place(relx=0.15,rely=0.75,relwidth=0.15)
resultado_exemplo2_texto=Label( text="Exemplo 2",
font=("Arial","12","bold"),bg="#c1d5ee")
resultado_exemplo2_texto.place(relx=0.45,rely=0.7)
resultado_exemplo2=Label( textvariable=exemplo2)
resultado_exemplo2.place(relx=0.45,rely=0.75,relwidth=0.15)
resultado_exemplo3_texto=Label( text="Exemplo 3",
font=("Arial","12","bold"),bg="#c1d5ee")
resultado_exemplo3_texto.place(relx=0.7,rely=0.7)
resultado_exemplo3=Label( textvariable=exemplo3)
resultado_exemplo3.place(relx=0.7,rely=0.75,relwidth=0.15)
root.mainloop()