from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#10659e")
root.title("Calcular Valor Ajustado")
titulo = Label(text="Calcular Valor Ajustado",
font=("Arial", "25", "bold"),bg="#10659e",fg="#d9ead3")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(text="Valor Original:",
font=("Arial", "15", "bold"),bg="#10659e",fg="#d9ead3")
texto_sub1.place(relx=0.15, rely=0.25)
texto_sub2 = Label(text="Indice Inicial:",
font=("Arial", "15", "bold"),bg="#10659e",fg="#d9ead3")
texto_sub2.place(relx=0.15, rely=0.35)
texto_sub3 = Label(text="Indice Final:",
font=("Arial", "15", "bold"),bg="#10659e",fg="#d9ead3")
texto_sub3.place(relx=0.15, rely=0.45)
Valor_Original = DoubleVar()
Valor_Original_entrada = Entry(textvariable=Valor_Original,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Valor_Original_entrada.place(relx=0.55, rely=0.25, relwidth=0.35)
Indice_Inicial = DoubleVar()
Indice_Inicial_entrada = Entry(textvariable=Indice_Inicial,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Indice_Inicial_entrada.place(relx=0.55, rely=0.35, relwidth=0.35)
Indice_Final = DoubleVar()
Indice_Final_entrada = Entry(textvariable=Indice_Final,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Indice_Final_entrada.place(relx=0.55, rely=0.45, relwidth=0.35)
def limpar():
Indice_Final_entrada.delete(0, END)
Indice_Inicial_entrada.delete(0, END)
Valor_Original_entrada.delete(0, END)
resultado.set("")
def app():
ind_inicial = Indice_Inicial.get()
ind_final = Indice_Final.get()
v_original = Valor_Original.get()
valor_ajustado = v_original * (ind_final / ind_inicial)
valor_ajustadoarr = round(valor_ajustado,2)
mensagem = f'Valor ajustado: {valor_ajustadoarr}.'
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.73, relwidth=0.9,relheight=0.2)
root.mainloop()