inserito resource monitor nella gui e rivista l'interfaccia

This commit is contained in:
VALLONGOL 2025-11-26 09:31:10 +01:00
parent 562d074eb6
commit f0c3047437
3 changed files with 1136 additions and 14 deletions

File diff suppressed because it is too large Load Diff

View File

@ -48,8 +48,16 @@ class App(tk.Tk):
self.export_btn = ttk.Button(actions_frame, text="Export CSV", command=self._on_action_export, state="disabled") self.export_btn = ttk.Button(actions_frame, text="Export CSV", command=self._on_action_export, state="disabled")
self.export_btn.grid(row=0, column=5, padx=(4,4)) self.export_btn.grid(row=0, column=5, padx=(4,4))
# Shared progress bar used by all actions # Progress frame: progress bar and file counter below Actions
# Note: progress bar and counters moved to a bottom status bar below Results progress_frame = ttk.Frame(self)
progress_frame.pack(fill="x", side="top", padx=8, pady=(0,6))
ttk.Label(progress_frame, text="Progress:").pack(side="left", padx=(6,6))
self.progress = ttk.Progressbar(progress_frame, mode="determinate")
self.progress.pack(side="left", fill="x", expand=True, padx=(0,12))
self._lbl_files = ttk.Label(progress_frame, text="Files: 0/0")
self._lbl_files.pack(side="right", padx=(6,6))
# Results frame contains a single Treeview that will be reused by all actions # Results frame contains a single Treeview that will be reused by all actions
results_frame = ttk.LabelFrame(self, text="Results") results_frame = ttk.LabelFrame(self, text="Results")
@ -74,19 +82,33 @@ class App(tk.Tk):
# Keep the notebook and individual tabs instantiated for compatibility (not packed) # Keep the notebook and individual tabs instantiated for compatibility (not packed)
self.notebook = ttk.Notebook(self) self.notebook = ttk.Notebook(self)
# Status bar at the bottom: phase label, wide progress bar, and file counter # Status bar at the bottom: operation status (left) and resource monitor (right)
status_frame = ttk.Frame(self) status_frame = ttk.Frame(self, relief=tk.SUNKEN, borderwidth=1)
status_frame.pack(fill="x", side="bottom", padx=6, pady=(0,6)) status_frame.pack(fill="x", side="bottom", padx=0, pady=0)
self.phase_var = tk.StringVar(value="Idle")
self._lbl_phase = ttk.Label(status_frame, textvariable=self.phase_var)
self._lbl_phase.pack(side="left", padx=(6,12))
self.progress = ttk.Progressbar(status_frame, mode="determinate")
self.progress.pack(side="left", fill="x", expand=True, padx=(0,12))
# file counter on the right of the status bar
self._lbl_files = ttk.Label(status_frame, text="Files: 0/0")
self._lbl_files.pack(side="right", padx=(6,6))
# Log frame below the status bar # Left side: operation status
self.phase_var = tk.StringVar(value="Ready")
self._lbl_phase = ttk.Label(status_frame, textvariable=self.phase_var, anchor="w")
self._lbl_phase.pack(side="left", padx=(6,12))
# Right side: resource monitor
from resource_monitor import TkinterResourceMonitor
self.resource_var = tk.StringVar(value="CPU: 0% | RAM: 0 MB | Threads: 0")
self._lbl_resources = ttk.Label(status_frame, textvariable=self.resource_var, anchor="e")
self._lbl_resources.pack(side="right", padx=(12,6))
# Initialize and start resource monitor
try:
self.resource_monitor = TkinterResourceMonitor(
tk_widget=self,
string_var=self.resource_var,
poll_interval=1.0 # Update every second
)
self.resource_monitor.start()
except Exception as e:
self.log(f"Resource monitor not available: {e}", level="WARNING")
# Log frame above the status bar
log_frame = ttk.LabelFrame(self, text="Log") log_frame = ttk.LabelFrame(self, text="Log")
log_frame.pack(fill="x", side="bottom", padx=6, pady=(0,6)) log_frame.pack(fill="x", side="bottom", padx=6, pady=(0,6))
# ScrolledText for logs (read-only) # ScrolledText for logs (read-only)
@ -980,10 +1002,19 @@ class App(tk.Tk):
def on_closing(self): def on_closing(self):
"""Cleanup when closing the application.""" """Cleanup when closing the application."""
try: try:
# Stop resource monitor
if hasattr(self, 'resource_monitor'):
self.resource_monitor.stop()
except Exception:
pass
try:
# Shutdown logger system
if hasattr(self, 'logger_system'): if hasattr(self, 'logger_system'):
self.logger_system.shutdown() self.logger_system.shutdown()
except Exception: except Exception:
pass pass
self.destroy() self.destroy()

View File

@ -1,3 +1,4 @@
pygount pygount
lizard lizard
Pygments Pygments
psutil