Mundo em Python

Calcular a Comissão

from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#5e92b8")
root.title("Calcular a Comissão")
titulo = Label(text="Calcular a Comissão",
font=("Arial", "27", "bold"),bg="#5e92b8",fg="#d9ead3")
titulo.place(relx=0.08, rely=0.05)
texto_sub1 = Label(text="Valor Total da Venda:",
font=("Arial", "16", "bold"),bg="#5e92b8",fg="#d9ead3")
texto_sub1.place(relx=0.1, rely=0.27) texto_sub2 = Label(text="Taxa de Comissão (%):",
font=("Arial", "16", "bold"),bg="#5e92b8",fg="#d9ead3")
texto_sub2.place(relx=0.05, rely=0.45) Valor_Total_Venda = DoubleVar()
Valor_Total_Venda_entrada = Entry(textvariable=Valor_Total_Venda,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Valor_Total_Venda_entrada.place(relx=0.65, rely=0.27, relwidth=0.3)
Taxa_Comissão = DoubleVar()
Taxa_Comissão_entrada = Entry(textvariable=Taxa_Comissão,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Taxa_Comissão_entrada.place(relx=0.65, rely=0.45, relwidth=0.3)
def limpar():
Taxa_Comissão_entrada.delete(0, END)
Valor_Total_Venda_entrada.delete(0, END)
resultado.set("") def app():
Tx_comissao = Taxa_Comissão.get()
Tx_comissaopp =Tx_comissao / 100
total_venda=Valor_Total_Venda.get()
comissao = total_venda * Tx_comissaopp
euro_symbol = "\u20AC"
mensagem=f"A comissão a ser paga é: {euro_symbol} {round(comissao,2)}. "
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.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.75, relwidth=0.9,relheight=0.2)
root.mainloop()
0