-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenhanced_features.py
More file actions
186 lines (150 loc) · 8.21 KB
/
enhanced_features.py
File metadata and controls
186 lines (150 loc) · 8.21 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import tkinter as tk
from tkinter import ttk, messagebox, filedialog, scrolledtext
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.animation import FuncAnimation
import numpy as np
import threading
import time
import json
import queue
import os
import sys
import subprocess
import re
from datetime import datetime, timedelta
from collections import deque
import webbrowser
class BatchCommandManager:
"""Gestor de comandos en lote"""
def __init__(self, main_app):
self.main_app = main_app
self.batch_queue = queue.Queue()
self.is_running = False
self.current_batch = []
self.results = []
def create_batch_interface(self, parent):
"""Crear interfaz para comandos en lote"""
batch_frame = tk.Frame(parent, bg='#2d2d2d')
batch_frame.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
tk.Label(batch_frame, text="🔄 Modo Batch - Comandos en Lote",
font=("Segoe UI", 14, "bold"),
bg='#2d2d2d', fg='white').pack(pady=(0, 10), anchor='w')
# Lista de comandos y botones
list_frame = tk.LabelFrame(batch_frame, text="📋 Comandos en el Lote",
bg='#2d2d2d', fg='white', font=("Segoe UI", 10, "bold"))
list_frame.pack(fill=tk.BOTH, expand=True, pady=(0, 10))
columns = ('#', 'Herramienta', 'Parámetros', 'Estado')
self.batch_tree = ttk.Treeview(list_frame, columns=columns, show='headings', height=10)
self.batch_tree.heading('#', text='#')
self.batch_tree.column('#', width=40, anchor='center')
self.batch_tree.heading('Herramienta', text='Herramienta')
self.batch_tree.heading('Parámetros', text='Parámetros')
self.batch_tree.heading('Estado', text='Estado')
self.batch_tree.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
# Botones de control del lote
btn_frame = tk.Frame(batch_frame, bg='#2d2d2d')
btn_frame.pack(fill=tk.X, pady=(0, 10))
tk.Button(btn_frame, text="➕ Agregar", command=self.add_command_dialog, bg='#007acc', fg='white').pack(side=tk.LEFT, padx=2)
self.run_batch_btn = tk.Button(btn_frame, text="▶️ Ejecutar", command=self.run_batch, bg='#28a745', fg='white')
self.run_batch_btn.pack(side=tk.LEFT, padx=2)
tk.Button(btn_frame, text="🗑️ Limpiar", command=self.clear_batch, bg='#dc3545', fg='white').pack(side=tk.LEFT, padx=2)
tk.Button(btn_frame, text="💾 Guardar", command=self.save_batch, bg='#6c757d', fg='white').pack(side=tk.LEFT, padx=2)
tk.Button(btn_frame, text="📂 Cargar", command=self.load_batch, bg='#6c757d', fg='white').pack(side=tk.LEFT, padx=2)
tk.Button(btn_frame, text="📄 Exportar Resultados", command=self.export_results, bg='#17a2b8', fg='white').pack(side=tk.RIGHT, padx=2)
return batch_frame
def add_command_dialog(self):
messagebox.showinfo("Info", "Funcionalidad 'Agregar Comando' no implementada en este ejemplo.")
def run_batch(self):
messagebox.showinfo("Info", "Funcionalidad 'Ejecutar Lote' no implementada en este ejemplo.")
def clear_batch(self):
messagebox.showinfo("Info", "Funcionalidad 'Limpiar Lote' no implementada en este ejemplo.")
def save_batch(self):
messagebox.showinfo("Info", "Funcionalidad 'Guardar Lote' no implementada en este ejemplo.")
def load_batch(self):
messagebox.showinfo("Info", "Funcionalidad 'Cargar Lote' no implementada en este ejemplo.")
def export_results(self):
messagebox.showinfo("Info", "Funcionalidad 'Exportar Resultados' no implementada en este ejemplo.")
class SystemNotificationManager:
"""Gestor de notificaciones del sistema"""
def __init__(self):
self.notifications_enabled = True
def show_notification(self, title, message):
"""Mostrar notificación usando messagebox como fallback universal"""
if not self.notifications_enabled:
return
try:
messagebox.showinfo(title, message)
except Exception as e:
print(f"Error mostrando notificación: {e}")
def notify_command_completed(self, command_name, success=True, duration=None):
if success:
title = "✅ Comando Completado"
message = f"'{command_name}' ejecutado exitosamente"
if duration:
message += f" en {duration:.1f}s"
else:
title = "❌ Comando Fallido"
message = f"'{command_name}' falló durante la ejecución"
self.show_notification(title, message)
class EnhancedNetworkApp:
"""Clase que agrupa e inicializa todas las nuevas características."""
def __init__(self, base_app):
self.base_app = base_app
self.root = base_app.root
self.notification_manager = SystemNotificationManager()
self.batch_manager = BatchCommandManager(self.base_app)
self.setup_ui_enhancements()
self.setup_options_menu()
self.integrate_with_command_system()
def setup_ui_enhancements(self):
"""Crear las nuevas pestañas en el notebook principal."""
notebook = self.base_app.notebook
# Pestaña de Comandos en Lote
batch_tab = tk.Frame(notebook, bg='#1e1e1e')
notebook.add(batch_tab, text="🔄 Comandos en Lote")
self.batch_manager.create_batch_interface(batch_tab)
def setup_options_menu(self):
"""Configurar menú de opciones avanzadas."""
if not hasattr(self.root, 'menubar'):
menubar = tk.Menu(self.root)
self.root.config(menu=menubar)
self.root.menubar = menubar
else:
menubar = self.root.menubar
tools_menu = tk.Menu(menubar, tearoff=0)
menubar.add_cascade(label="🔧 Herramientas Avanzadas", menu=tools_menu)
tools_menu.add_command(label="Recargar Plugins (simulado)",
command=lambda: messagebox.showinfo("Plugins", "Simulación de recarga de plugins."))
tools_menu.add_separator()
tools_menu.add_command(label="Acerca de", command=self.show_about)
def integrate_with_command_system(self):
"""Integrar con el sistema de comandos para notificaciones."""
original_finished_callback = self.base_app.on_command_finished
def finished_callback_with_notification():
original_finished_callback()
self.notification_manager.notify_command_completed(self.base_app.current_tool, success=True)
self.base_app.on_command_finished = finished_callback_with_notification
def show_about(self):
"""Mostrar información sobre la aplicación"""
about_window = tk.Toplevel(self.root)
about_window.title("ℹ️ Acerca de Network Tools Pro")
about_window.geometry("400x250")
about_window.configure(bg='#1e1e1e')
about_window.resizable(False, False)
main_frame = tk.Frame(about_window, bg='#1e1e1e', pady=15)
main_frame.pack(expand=True, fill=tk.BOTH)
tk.Label(main_frame, text="🌐 Network Tools Pro v2.0", font=("Segoe UI", 14, "bold"), fg='white', bg='#1e1e1e').pack(pady=(0, 10))
info_text = "Suite de herramientas para diagnóstico de red."
tk.Label(main_frame, text=info_text, fg='#cccccc', bg='#1e1e1e', justify=tk.CENTER).pack()
tk.Label(main_frame, text=f"Python {sys.version.split()[0]} | Tkinter", fg='#999999', bg='#1e1e1e').pack(pady=5)
creator_frame = tk.Frame(main_frame, bg='#1e1e1e')
creator_frame.pack(pady=10)
tk.Label(creator_frame, text="Creado por:", fg='#cccccc', bg='#1e1e1e').pack(side=tk.LEFT)
link = tk.Label(creator_frame, text="Ez07-Code", fg="#007acc", cursor="hand2", bg='#1e1e1e')
link.pack(side=tk.LEFT, padx=5)
link.bind("<Button-1>", lambda e: webbrowser.open_new("https://github.com/Ez07-Code"))
separator = ttk.Separator(main_frame, orient='horizontal')
separator.pack(fill='x', padx=20, pady=10)
ok_button = tk.Button(main_frame, text="OK", command=about_window.destroy, bg='#007acc', fg='white', width=10)
ok_button.pack(pady=10)