from tkinter import *
root = Tk()
root.geometry("700x500")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Simulador de Produção")
# Título
titulo = Label(
text="Simulador de Produção",
font=("Arial", 28, "bold"),
bg="#103030",
fg="#49e3e3"
)
titulo.place(relx=0.15, rely=0.05)
# Labels
texto_sub1 = Label(
text="Produção por hora:",
font=("Arial", 18, "bold"),
bg="#103030",
fg="#49e3e3"
)
texto_sub1.place(relx=0.2, rely=0.23)
texto_sub2 = Label(
text="Meta total:",
font=("Arial", 18, "bold"),
bg="#103030",
fg="#49e3e3"
)
texto_sub2.place(relx=0.35, rely=0.35)
texto_sub3 = Label(
text="Horas trabalhadas:",
font=("Arial", 18, "bold"),
bg="#103030",
fg="#49e3e3"
)
texto_sub3.place(relx=0.22, rely=0.5)
# Entradas
Produção_hora = StringVar()
Produção_hora_entrada = Entry(
textvariable=Produção_hora,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
Produção_hora_entrada.place(relx=0.58, rely=0.24, relwidth=0.35)
Produção_hora_entrada.focus()
Meta_total = StringVar()
Meta_total_entrada = Entry(
textvariable=Meta_total,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
Meta_total_entrada.place(relx=0.58, rely=0.36, relwidth=0.35)
Horas_trabalhadas = StringVar()
Horas_trabalhadas_entrada = Entry(
textvariable=Horas_trabalhadas,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
Horas_trabalhadas_entrada.place(relx=0.58, rely=0.51, relwidth=0.35)
# Funções
def limpar():
Horas_trabalhadas_entrada.delete(0, END)
Meta_total_entrada.delete(0, END)
Produção_hora_entrada.delete(0, END)
resultado_texto.config(text="", fg="black")
def app():
try:
h_trabalhadas = float(Horas_trabalhadas.get())
m_total = float(Meta_total.get())
prod_hora = float(Produção_hora.get())
producao_real = prod_hora * h_trabalhadas
if m_total == 0:
percentual = 0
else:
percentual = (producao_real / m_total) * 100
# Cor dinâmica
if percentual >= 100:
cor = "green"
else:
cor = "red"
resultado_texto.config(
text=f"Produção Total: {producao_real:.2f} | Atingimento: {percentual:.2f}%",
fg=cor
)
except ValueError:
resultado_texto.config(
text="Por favor, insira valores numéricos válidos.",
fg="orange"
)
# Botões
but1 = Button(
text="Calcular",
bd=2,
bg='#107db2',
fg='white',
font=('verdana', 12, 'bold'),
command=app
)
but1.place(relx=0.1, rely=0.65, 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.4, rely=0.65, 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.7, rely=0.65, relwidth=0.25, relheight=0.1)
# Resultado
resultado_texto = Label(
text="",
font=("Arial", 12, "bold"),
bg="#cfe2f3"
)
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9, relheight=0.15)
root.mainloop()