Mundo em Python

Calcular Imposto Rendimento

from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#0e629e")
root.title("Calcular Imposto Rendimento")
titulo = Label(text="Calcular Imposto Rendimento",
font=("Arial", "18", "bold"),bg="#0e629e",fg="#d9ead3")
titulo.place(relx=0.08, rely=0.05)
texto_sub1 = Label(text="Rendimento anual \u20AC:",
font=("Arial", "15", "bold"),bg="#0e629e",fg="#d9ead3")
texto_sub1.place(relx=0.05, rely=0.35) Rendimento_anual = DoubleVar()
Rendimento_anual_entrada = Entry(textvariable=Rendimento_anual,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Rendimento_anual_entrada.place(relx=0.65, rely=0.35, relwidth=0.3)
def limpar():
Rendimento_anual_entrada.delete(0, END)
resultado.set("")
def app():
ra = Rendimento_anual.get()
if ra <= 50000:
taxa_imposto = 0.1
elif ra <= 100000:
taxa_imposto = 0.15
else:
taxa_imposto = 0.2
imposto_pagar = ra * taxa_imposto
mensagem = f"Imposto a Pagar: {imposto_pagar} \u20AC"
resultado.set(mensagem)
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, rely=0.55, 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.55, 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.55, 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.7, relwidth=0.9,relheight=0.2) root.mainloop()
0