aggiunti eta
This commit is contained in:
parent
fae76bf10b
commit
439ac6e4b5
@ -57,6 +57,9 @@ class BackupApplicationWindow:
|
|||||||
self._included_ext_stats: dict = {}
|
self._included_ext_stats: dict = {}
|
||||||
self._excluded_ext_stats: dict = {}
|
self._excluded_ext_stats: dict = {}
|
||||||
self._confirmation_dialog_active = False
|
self._confirmation_dialog_active = False
|
||||||
|
# Timestamps for ETA calculations
|
||||||
|
self._scan_start_time = None
|
||||||
|
self._zip_start_time = None
|
||||||
|
|
||||||
self._setup_styles()
|
self._setup_styles()
|
||||||
self._create_widgets()
|
self._create_widgets()
|
||||||
@ -167,6 +170,8 @@ class BackupApplicationWindow:
|
|||||||
self.status_file_label.grid(row=0, column=0, sticky="ew", padx=5)
|
self.status_file_label.grid(row=0, column=0, sticky="ew", padx=5)
|
||||||
self.status_size_label = ttk.Label(status_bar_frame, text="Size: 0.00 MB / 0.00 MB", anchor="e", width=30)
|
self.status_size_label = ttk.Label(status_bar_frame, text="Size: 0.00 MB / 0.00 MB", anchor="e", width=30)
|
||||||
self.status_size_label.grid(row=0, column=1, sticky="e", padx=5)
|
self.status_size_label.grid(row=0, column=1, sticky="e", padx=5)
|
||||||
|
self.status_time_label = ttk.Label(status_bar_frame, text="", anchor="e", width=40)
|
||||||
|
self.status_time_label.grid(row=0, column=2, sticky="e", padx=5)
|
||||||
|
|
||||||
# Permetti alla riga delle esclusioni di espandersi se necessario
|
# Permetti alla riga delle esclusioni di espandersi se necessario
|
||||||
main_frame.rowconfigure(3, weight=1)
|
main_frame.rowconfigure(3, weight=1)
|
||||||
@ -282,6 +287,19 @@ class BackupApplicationWindow:
|
|||||||
self.config_data.pop("last_active_profile", None)
|
self.config_data.pop("last_active_profile", None)
|
||||||
app_settings.save_application_data(self.config_data)
|
app_settings.save_application_data(self.config_data)
|
||||||
|
|
||||||
|
def _format_seconds(self, seconds: float) -> str:
|
||||||
|
"""Return a human readable H:MM:SS for given seconds."""
|
||||||
|
try:
|
||||||
|
s = int(round(seconds))
|
||||||
|
hrs = s // 3600
|
||||||
|
mins = (s % 3600) // 60
|
||||||
|
secs = s % 60
|
||||||
|
if hrs:
|
||||||
|
return f"{hrs}:{mins:02d}:{secs:02d}"
|
||||||
|
return f"{mins:02d}:{secs:02d}"
|
||||||
|
except Exception:
|
||||||
|
return "--:--"
|
||||||
|
|
||||||
def _browse_directory(self, dir_var: StringVar) -> None:
|
def _browse_directory(self, dir_var: StringVar) -> None:
|
||||||
current_path = dir_var.get()
|
current_path = dir_var.get()
|
||||||
initial_dir = current_path if Path(current_path).is_dir() else str(Path.home())
|
initial_dir = current_path if Path(current_path).is_dir() else str(Path.home())
|
||||||
@ -370,6 +388,20 @@ class BackupApplicationWindow:
|
|||||||
display_path = Path(current_file_path).name
|
display_path = Path(current_file_path).name
|
||||||
self.status_file_label.config(text=f"Scanning: {display_path}")
|
self.status_file_label.config(text=f"Scanning: {display_path}")
|
||||||
self.status_size_label.config(text=f"File {current_file_idx+1}/{total_files}")
|
self.status_size_label.config(text=f"File {current_file_idx+1}/{total_files}")
|
||||||
|
# ETA / elapsed calculation
|
||||||
|
try:
|
||||||
|
if not self._scan_start_time:
|
||||||
|
self._scan_start_time = datetime.now()
|
||||||
|
elapsed = (datetime.now() - self._scan_start_time).total_seconds()
|
||||||
|
frac = (current_file_idx + 1) / total_files if total_files > 0 else 0
|
||||||
|
if frac > 0:
|
||||||
|
remaining = elapsed * (1.0 / frac - 1.0)
|
||||||
|
eta_text = f"Elapsed: {self._format_seconds(elapsed)} | ETA: {self._format_seconds(remaining)}"
|
||||||
|
else:
|
||||||
|
eta_text = f"Elapsed: {self._format_seconds(elapsed)} | ETA: --:--"
|
||||||
|
self.status_time_label.config(text=eta_text)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
self.root.update_idletasks()
|
self.root.update_idletasks()
|
||||||
|
|
||||||
def _update_zip_progress(self, processed_mb: float, total_mb: float, arcname: str) -> None:
|
def _update_zip_progress(self, processed_mb: float, total_mb: float, arcname: str) -> None:
|
||||||
@ -379,12 +411,33 @@ class BackupApplicationWindow:
|
|||||||
display_arcname = Path(arcname).name
|
display_arcname = Path(arcname).name
|
||||||
self.status_file_label.config(text=f"Archiving: {display_arcname}")
|
self.status_file_label.config(text=f"Archiving: {display_arcname}")
|
||||||
self.status_size_label.config(text=f"{processed_mb:.2f} MB / {total_mb:.2f} MB")
|
self.status_size_label.config(text=f"{processed_mb:.2f} MB / {total_mb:.2f} MB")
|
||||||
|
# ETA / elapsed calculation for zip
|
||||||
|
try:
|
||||||
|
if not self._zip_start_time:
|
||||||
|
self._zip_start_time = datetime.now()
|
||||||
|
elapsed = (datetime.now() - self._zip_start_time).total_seconds()
|
||||||
|
frac = (processed_mb / total_mb) if total_mb > 0 else 0
|
||||||
|
if frac > 0:
|
||||||
|
remaining = elapsed * (1.0 / frac - 1.0)
|
||||||
|
eta_text = f"Elapsed: {self._format_seconds(elapsed)} | ETA: {self._format_seconds(remaining)}"
|
||||||
|
else:
|
||||||
|
eta_text = f"Elapsed: {self._format_seconds(elapsed)} | ETA: --:--"
|
||||||
|
self.status_time_label.config(text=eta_text)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
self.root.update_idletasks()
|
self.root.update_idletasks()
|
||||||
|
|
||||||
def _reset_progress_status(self, message: str = "Idle") -> None:
|
def _reset_progress_status(self, message: str = "Idle") -> None:
|
||||||
self.progress_bar["value"] = 0
|
self.progress_bar["value"] = 0
|
||||||
self.status_file_label.config(text=f"Status: {message}")
|
self.status_file_label.config(text=f"Status: {message}")
|
||||||
self.status_size_label.config(text="Size: 0.00 MB / 0.00 MB")
|
self.status_size_label.config(text="Size: 0.00 MB / 0.00 MB")
|
||||||
|
# clear ETA timestamps and label
|
||||||
|
self._scan_start_time = None
|
||||||
|
self._zip_start_time = None
|
||||||
|
try:
|
||||||
|
self.status_time_label.config(text="")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
def _toggle_ui_elements(self, enabled: bool) -> None:
|
def _toggle_ui_elements(self, enabled: bool) -> None:
|
||||||
state_tk_text = tk.NORMAL if enabled else tk.DISABLED
|
state_tk_text = tk.NORMAL if enabled else tk.DISABLED
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user