Mundo em Python

Taxa de Crescimento de Vendas

from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#114dcf")
root.title("Taxa de Crescimento de Vendas")
def limpar():
Vendas_Actuais_entrada.delete(0, END)
Vendas_Anteriores_entrada.delete(0, END)
def app():
vendas_actuais =Vendas_Actuais.get()
vendas_anteriores = Vendas_Anteriores.get()
taxa_crescimento = ((vendas_actuais - vendas_anteriores) / vendas_anteriores) * 100
taxa_crescimentopp = round(taxa_crescimento,2)
mensagem = f"A taxa de crescimento de vendas é: {taxa_crescimentopp}%"
resultado.set(mensagem)
titulo = Label(text="Taxa de Crescimento de Vendas",
font=("Arial", "19", "bold"),bg="#114dcf",fg="#e9f2f1")
titulo.place(relx=0.03, rely=0.05)
texto_sub1 = Label(text="Vendas Anteriores:",
font=("Arial", "15", "bold"),bg="#114dcf",fg="#e9f2f1")
texto_sub1.place(relx=0.1, rely=0.25) texto_sub2 = Label(text="Vendas Actuais:",
font=("Arial", "15", "bold"),bg="#114dcf",fg="#e9f2f1")
texto_sub2.place(relx=0.15, rely=0.4) Vendas_Anteriores = DoubleVar()
Vendas_Anteriores_entrada = Entry(textvariable=Vendas_Anteriores,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Vendas_Anteriores_entrada.place(relx=0.6, rely=0.25, relwidth=0.3) Vendas_Actuais = DoubleVar()
Vendas_Actuais_entrada = Entry(textvariable=Vendas_Actuais,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Vendas_Actuais_entrada.place(relx=0.6, rely=0.4, relwidth=0.3)
but1 = Button(text="Verificar", 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.75, relwidth=0.9,relheight=0.1)
root.mainloop()
0