Mundo em Python

Taxa de Poupança (usando Tkinter)

from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#084f9c")
root.title("Taxa de Poupança")
titulo = Label(text="Taxa de Poupança",
font=("Arial", "31", "bold"),bg="#084f9c",fg="#d9ead3")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(text="Valor da Economia:",
font=("Arial", "16", "bold"),bg="#084f9c",fg="#d9ead3")
texto_sub1.place(relx=0.15, rely=0.3) texto_sub2 = Label(text="Valor do Rendimento:",
font=("Arial", "16", "bold"),bg="#084f9c",fg="#d9ead3")
texto_sub2.place(relx=0.08, rely=0.45)
economia = DoubleVar()
economia_entrada = Entry(textvariable=economia,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
economia_entrada.place(relx=0.66, rely=0.3, relwidth=0.27) rendimento = DoubleVar()
rendimento_entrada = Entry(textvariable=rendimento,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
rendimento_entrada.place(relx=0.66, rely=0.45, relwidth=0.27) def limpar():
rendimento_entrada.delete(0, END)
economia_entrada.delete(0, END)
resultado.set("")
def app():
r = rendimento.get()
ve = economia.get()
taxa_poupanca = (ve / r) * 100
mensagem = f'A taxa de poupança é {round(taxa_poupanca,2)} %'
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.8, relwidth=0.9,relheight=0.1) root.mainloop()
0