Mundo em Python

Índice de Concentração de Clientes

from tkinter import *
root = Tk()
root.geometry("600x400")
root.resizable(0, 0)
root.config(bg="#0e4d47")
root.title("Índice de Concentração de Clientes")
titulo = Label(text="Índice de Concentração de Clientes",
font=("Arial", "25", "bold"),bg="#0e4d47",fg="#1ff2de")
titulo.place(relx=0.05,rely=0.05)
texto_sub1 = Label(text="Vendas para o Maior Cliente:",
font=("Arial", "14", "bold"),bg="#0e4d47",fg="#1ff2de")
texto_sub1.place(relx=0.15, rely=0.25) texto_sub2 = Label(text="Vendas Totais:",
font=("Arial", "14", "bold"),bg="#0e4d47",fg="#1ff2de")
texto_sub2.place(relx=0.35, rely=0.45)
Vendas_Maior_Cliente = DoubleVar()
Vendas_Maior_Cliente_entrada = Entry(textvariable=Vendas_Maior_Cliente,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Vendas_Maior_Cliente_entrada.place(relx=0.65, rely=0.25, relwidth=0.3) Vendas_Totais = DoubleVar()
Vendas_Totais_entrada = Entry(textvariable=Vendas_Totais,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Vendas_Totais_entrada.place(relx=0.65, rely=0.45, relwidth=0.3)
def app():
vt = Vendas_Totais.get()
cliente = Vendas_Maior_Cliente.get()
Indice_Concentracao_Cliente = (cliente/vt)*100
if Indice_Concentracao_Cliente<20:
classificacao = "Baixo Índice de Concentração (Baixo Risco)"
elif Indice_Concentracao_Cliente>50:
classificacao = "Alto Índice de Concentração (Alto Risco)"
else:
classificacao = "Moderado Índice de Concentração (Moderado Risco)"
mensagem = f"Índice Concentração do Cliente: {round(Indice_Concentracao_Cliente,2)} %\nClassificação: {classificacao}"
resultado.set(mensagem)
def limpar():
Vendas_Totais_entrada.delete(0, END)
Vendas_Maior_Cliente_entrada.delete(0, END)
resultado.set("")
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.25)
root.mainloop()
0