-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
90 lines (70 loc) · 3.09 KB
/
main.py
File metadata and controls
90 lines (70 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import tkinter as tk
from tkinter import ttk, messagebox
import pandas as pd
from fpdf import FPDF
# Función para cargar la información
def cargar_informacion():
fecha = entry_fecha.get()
hora_inicio = entry_hora_inicio.get()
hora_fin = entry_hora_fin.get()
barriles = entry_barriles.get()
fumigadores = entry_fumigadores.get()
if not all([fecha, hora_inicio, hora_fin, barriles, fumigadores]):
messagebox.showwarning("Campos incompletos", "Por favor, complete todos los campos")
return
datos.append([fecha, hora_inicio, hora_fin, barriles, fumigadores])
actualizar_resumen()
def actualizar_resumen():
texto_resumen.set(f"Fumigaciones registradas: {len(datos)}")
def exportar_excel():
df = pd.DataFrame(datos, columns=["Fecha", "Hora Inicio", "Hora Fin", "Barriles", "Fumigadores"])
df.to_excel("fumigaciones.xlsx", index=False)
messagebox.showinfo("Éxito", "Datos exportados a Excel correctamente")
def exportar_pdf():
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)
pdf.cell(200, 10, "Informe de Fumigaciones", ln=True, align='C')
pdf.ln(10)
for row in datos:
pdf.cell(200, 10, f"{row}", ln=True)
pdf.output("fumigaciones.pdf")
messagebox.showinfo("Éxito", "Datos exportados a PDF correctamente")
# Interfaz gráfica
root = tk.Tk()
root.title("Registro de Fumigaciones")
root.geometry("400x350")
root.resizable(False, False)
style = ttk.Style()
style.theme_use("clam")
style.configure("TButton", font=("Arial", 10), padding=5)
style.configure("TLabel", font=("Arial", 10))
style.configure("TEntry", padding=5)
datos = []
texto_resumen = tk.StringVar()
texto_resumen.set("Fumigaciones registradas: 0")
frame = ttk.Frame(root, padding=10)
frame.grid(row=0, column=0, sticky="nsew")
# Entradas de datos
ttk.Label(frame, text="Fecha de Fumigación:").grid(row=0, column=0, sticky="w", pady=2)
entry_fecha = ttk.Entry(frame)
entry_fecha.grid(row=0, column=1, pady=2)
ttk.Label(frame, text="Hora de Inicio:").grid(row=1, column=0, sticky="w", pady=2)
entry_hora_inicio = ttk.Entry(frame)
entry_hora_inicio.grid(row=1, column=1, pady=2)
ttk.Label(frame, text="Hora de Finalización:").grid(row=2, column=0, sticky="w", pady=2)
entry_hora_fin = ttk.Entry(frame)
entry_hora_fin.grid(row=2, column=1, pady=2)
ttk.Label(frame, text="Barriles Utilizados:").grid(row=3, column=0, sticky="w", pady=2)
entry_barriles = ttk.Entry(frame)
entry_barriles.grid(row=3, column=1, pady=2)
ttk.Label(frame, text="Número de Fumigadores:").grid(row=4, column=0, sticky="w", pady=2)
entry_fumigadores = ttk.Entry(frame)
entry_fumigadores.grid(row=4, column=1, pady=2)
# Botones
ttk.Button(frame, text="Cargar Información", command=cargar_informacion).grid(row=5, column=0, columnspan=2, pady=5)
ttk.Button(frame, text="Exportar a Excel", command=exportar_excel).grid(row=6, column=0, pady=5)
ttk.Button(frame, text="Exportar a PDF", command=exportar_pdf).grid(row=6, column=1, pady=5)
# Resumen
ttk.Label(frame, textvariable=texto_resumen, font=("Arial", 10, "bold")).grid(row=7, column=0, columnspan=2, pady=10)
root.mainloop()