fix MessageDialog, rename variables

This commit is contained in:
2025-09-11 13:11:14 +02:00
parent 22144859d8
commit d7dd4215c0
8 changed files with 73 additions and 56 deletions

View File

@@ -98,7 +98,7 @@ class MainApplication(tk.Tk):
self.actions = Actions(self)
self.full_backup_var = tk.BooleanVar()
self.inkrementell_var = tk.BooleanVar()
self.incremental_var = tk.BooleanVar()
self.genaue_berechnung_var = tk.BooleanVar()
self.test_run_var = tk.BooleanVar()
self.compressed_var = tk.BooleanVar()
@@ -174,7 +174,7 @@ class MainApplication(tk.Tk):
self.test_run_cb = ttk.Checkbutton(self.sidebar_buttons_frame, text=Msg.STR["test_run"],
variable=self.test_run_var, style="Switch2.TCheckbutton")
self.test_run_cb.pack(fill=tk.X, pady=10)
self.test_run_cb.pack(fill=tk.X, pady=(100, 10))
self.bypass_security_cb = ttk.Checkbutton(self.sidebar_buttons_frame, text=Msg.STR["bypass_security"],
variable=self.bypass_security_var, style="Switch2.TCheckbutton")
self.bypass_security_cb.pack(fill=tk.X, pady=10)
@@ -488,10 +488,10 @@ class MainApplication(tk.Tk):
checkbox_frame.pack(fill=tk.X, pady=5)
self.full_backup_cb = ttk.Checkbutton(checkbox_frame, text=Msg.STR["full_backup"],
variable=self.full_backup_var, command=lambda: self.actions.handle_backup_type_change('voll'), style="Switch.TCheckbutton")
variable=self.full_backup_var, command=lambda: self.actions.handle_backup_type_change('full'), style="Switch.TCheckbutton")
self.full_backup_cb.pack(side=tk.LEFT, padx=5)
self.incremental_cb = ttk.Checkbutton(checkbox_frame, text=Msg.STR["incremental"],
variable=self.inkrementell_var, command=lambda: self.actions.handle_backup_type_change('inkrementell'), style="Switch.TCheckbutton")
variable=self.incremental_var, command=lambda: self.actions.handle_backup_type_change('incremental'), style="Switch.TCheckbutton")
self.incremental_cb.pack(side=tk.LEFT, padx=5)
self.compressed_cb = ttk.Checkbutton(checkbox_frame, text=Msg.STR["compressed"],
@@ -535,7 +535,8 @@ class MainApplication(tk.Tk):
self.start_pause_button.grid(row=0, column=2, rowspan=2, padx=5)
def on_closing(self):
self.config_manager.set_setting("refresh_log", self.refresh_log_var.get())
self.config_manager.set_setting(
"refresh_log", self.refresh_log_var.get())
self.backup_manager.encryption_manager.unmount_all()
self.config_manager.set_setting("last_mode", self.mode)
@@ -795,12 +796,12 @@ class MainApplication(tk.Tk):
if force_full:
self.full_backup_var.set(True)
self.inkrementell_var.set(False)
self.incremental_var.set(False)
self.full_backup_cb.config(state="disabled")
self.incremental_cb.config(state="disabled")
elif force_incremental:
self.full_backup_var.set(False)
self.inkrementell_var.set(True)
self.incremental_var.set(True)
self.full_backup_cb.config(state="disabled")
self.incremental_cb.config(state="disabled")

View File

@@ -21,10 +21,10 @@ class Actions:
def _set_backup_type(self, backup_type: str):
if backup_type == "full":
self.app.full_backup_var.set(True)
self.app.inkrementell_var.set(False)
self.app.incremental_var.set(False)
elif backup_type == "incremental":
self.app.full_backup_var.set(False)
self.app.inkrementell_var.set(True)
self.app.incremental_var.set(True)
def _update_backup_type_controls(self):
source_name = self.app.left_canvas_data.get('folder')
@@ -79,7 +79,7 @@ class Actions:
# Apply specific logic based on current states
if self.app.compressed_var.get():
# If compressed, cannot be incremental
self.app.inkrementell_var.set(False)
self.app.incremental_var.set(False)
self.app.full_backup_var.set(True) # Force full if compressed
self.app.incremental_cb.config(state="disabled")
# If compressed, cannot be encrypted
@@ -91,7 +91,7 @@ class Actions:
# If encrypted, cannot be compressed
self.app.compressed_var.set(False)
self.app.compressed_cb.config(state="disabled")
elif self.app.inkrementell_var.get():
elif self.app.incremental_var.get():
# If incremental, cannot be compressed
self.app.compressed_var.set(False)
self.app.compressed_cb.config(state="disabled")
@@ -100,11 +100,11 @@ class Actions:
self._update_backup_type_controls()
def handle_backup_type_change(self, changed_var_name):
if changed_var_name == 'voll':
if changed_var_name == 'full':
if self.app.full_backup_var.get():
self._set_backup_type("full")
elif changed_var_name == 'inkrementell':
if self.app.inkrementell_var.get():
elif changed_var_name == 'incremental':
if self.app.incremental_var.get():
self._set_backup_type("incremental")
def handle_compression_change(self):
@@ -159,11 +159,13 @@ class Actions:
exclude_files = []
if is_system:
if AppConfig.GENERATED_EXCLUDE_LIST_PATH.exists():
exclude_files.append(AppConfig.GENERATED_EXCLUDE_LIST_PATH)
exclude_files.append(
AppConfig.GENERATED_EXCLUDE_LIST_PATH)
if AppConfig.USER_EXCLUDE_LIST_PATH.exists():
exclude_files.append(AppConfig.USER_EXCLUDE_LIST_PATH)
if AppConfig.MANUAL_EXCLUDE_LIST_PATH.exists():
exclude_files.append(AppConfig.MANUAL_EXCLUDE_LIST_PATH)
exclude_files.append(
AppConfig.MANUAL_EXCLUDE_LIST_PATH)
size = self.app.backup_manager.estimate_incremental_size(
source_path=folder_path,
@@ -388,7 +390,7 @@ class Actions:
except FileNotFoundError:
with message_box_animation(self.app.animated_icon):
MessageDialog(master=self.app, message_type="error",
MessageDialog(message_type="error",
title=Msg.STR["error"], text=Msg.STR["path_not_found"].format(path=path)).show()
def reset_to_default_settings(self):
@@ -429,7 +431,7 @@ class Actions:
self.app.backup_content_frame.user_backups_frame._load_backup_content()
with message_box_animation(self.app.animated_icon):
MessageDialog(master=self.app, message_type="info",
MessageDialog(message_type="info",
title=Msg.STR["settings_reset_title"], text=Msg.STR["settings_reset_text"])
def _parse_size_string_to_bytes(self, size_str: str) -> int:
@@ -618,13 +620,13 @@ class Actions:
def _start_system_backup(self, mode, source_size_bytes):
base_dest = self.app.destination_path
if not base_dest:
MessageDialog(master=self.app, message_type="error",
MessageDialog(message_type="error",
title=Msg.STR["error"], text=Msg.STR["err_no_dest_folder"])
return
if base_dest.startswith("/home"):
with message_box_animation(self.app.animated_icon):
MessageDialog(master=self.app, message_type="error",
MessageDialog(message_type="error",
title=Msg.STR["error"], text=Msg.STR["system_backup_in_home_error"])
return
@@ -663,7 +665,7 @@ class Actions:
source_size_bytes = self.app.left_canvas_data.get('total_bytes', 0)
if not base_dest or not source_path:
MessageDialog(master=self.app, message_type="error",
MessageDialog(message_type="error",
title=Msg.STR["error"], text=Msg.STR["err_no_dest_folder"])
self.app.backup_is_running = False
self.app.start_pause_button["text"] = Msg.STR["start"]
@@ -694,4 +696,4 @@ class Actions:
is_encrypted=is_encrypted,
mode=mode,
use_trash_bin=use_trash_bin,
no_trash_bin=no_trash_bin)
no_trash_bin=no_trash_bin)

View File

@@ -132,15 +132,19 @@ class AdvancedSettingsFrame(ttk.Frame):
self.force_incremental_var, self.force_full_var, self.force_incremental_var.get()), style="Switch.TCheckbutton")
self.incremental_checkbutton.pack(anchor=tk.W)
self.compression_checkbutton = ttk.Checkbutton(self.backup_defaults_frame, text=Msg.STR["force_compression"], variable=self.force_compression_var, command=self._on_compression_toggle, style="Switch.TCheckbutton")
self.compression_checkbutton = ttk.Checkbutton(
self.backup_defaults_frame, text=Msg.STR["force_compression"], variable=self.force_compression_var, command=self._on_compression_toggle, style="Switch.TCheckbutton")
self.compression_checkbutton.pack(anchor=tk.W)
self.encryption_checkbutton = ttk.Checkbutton(self.backup_defaults_frame, text=Msg.STR["force_encryption"], variable=self.force_encryption_var, style="Switch.TCheckbutton")
self.encryption_checkbutton = ttk.Checkbutton(
self.backup_defaults_frame, text=Msg.STR["force_encryption"], variable=self.force_encryption_var, style="Switch.TCheckbutton")
self.encryption_checkbutton.pack(anchor=tk.W)
ttk.Separator(self.backup_defaults_frame, orient=tk.HORIZONTAL).pack(fill=tk.X, pady=10)
trash_info_label = ttk.Label(self.backup_defaults_frame, text=Msg.STR["trash_bin_explanation"], wraplength=750, justify="left")
ttk.Separator(self.backup_defaults_frame,
orient=tk.HORIZONTAL).pack(fill=tk.X, pady=10)
trash_info_label = ttk.Label(
self.backup_defaults_frame, text=Msg.STR["trash_bin_explanation"], wraplength=750, justify="left")
trash_info_label.pack(anchor=tk.W, pady=5)
ttk.Checkbutton(self.backup_defaults_frame, text=Msg.STR["use_trash_bin"], variable=self.use_trash_bin_var, command=lambda: self._handle_trash_checkbox_click(
@@ -148,7 +152,8 @@ class AdvancedSettingsFrame(ttk.Frame):
ttk.Checkbutton(self.backup_defaults_frame, text=Msg.STR["no_trash_bin"], variable=self.no_trash_bin_var, command=lambda: self._handle_trash_checkbox_click(
self.no_trash_bin_var, self.use_trash_bin_var), style="Switch.TCheckbutton").pack(anchor=tk.W)
ttk.Separator(self.backup_defaults_frame, orient=tk.HORIZONTAL).pack(fill=tk.X, pady=10)
ttk.Separator(self.backup_defaults_frame,
orient=tk.HORIZONTAL).pack(fill=tk.X, pady=10)
encryption_note = ttk.Label(
self.backup_defaults_frame, text=Msg.STR["encryption_note_system_backup"], wraplength=750, justify="left")
@@ -212,7 +217,8 @@ class AdvancedSettingsFrame(ttk.Frame):
self.encryption_checkbutton.config(state="normal")
def _handle_trash_checkbox_click(self, changed_var, other_var):
enforce_backup_type_exclusivity(changed_var, other_var, changed_var.get())
enforce_backup_type_exclusivity(
changed_var, other_var, changed_var.get())
self._on_trash_setting_change()
def _on_trash_setting_change(self):
@@ -234,7 +240,7 @@ class AdvancedSettingsFrame(ttk.Frame):
def _create_key_file(self):
if not self.app_instance.destination_path:
MessageDialog(self, message_type="error", title="Error",
MessageDialog(message_type="error", title="Error",
text="Please select a backup destination first.")
return
@@ -242,7 +248,7 @@ class AdvancedSettingsFrame(ttk.Frame):
self.app_instance.destination_path, "pybackup")
container_path = os.path.join(pybackup_dir, "pybackup_encrypted.luks")
if not os.path.exists(container_path):
MessageDialog(self, message_type="error", title="Error",
MessageDialog(message_type="error", title="Error",
text="No encrypted container found at the destination.")
return
@@ -257,10 +263,10 @@ class AdvancedSettingsFrame(ttk.Frame):
self.app_instance.destination_path, password)
if key_file_path:
MessageDialog(self, message_type="info", title="Success",
MessageDialog(message_type="info", title="Success",
text=f"Key file created and added successfully!\nPath: {key_file_path}")
else:
MessageDialog(self, message_type="error", title="Error",
MessageDialog(message_type="error", title="Error",
text="Failed to create or add key file. See log for details.")
self._update_key_file_status()
@@ -448,8 +454,10 @@ class AdvancedSettingsFrame(ttk.Frame):
"force_compression", self.force_compression_var.get())
self.config_manager.set_setting(
"force_encryption", self.force_encryption_var.get())
self.config_manager.set_setting("use_trash_bin", self.use_trash_bin_var.get())
self.config_manager.set_setting("no_trash_bin", self.no_trash_bin_var.get())
self.config_manager.set_setting(
"use_trash_bin", self.use_trash_bin_var.get())
self.config_manager.set_setting(
"no_trash_bin", self.no_trash_bin_var.get())
if self.app_instance:
self.app_instance.update_backup_options_from_config()
@@ -465,7 +473,8 @@ class AdvancedSettingsFrame(ttk.Frame):
self.app_instance.animated_icon = AnimatedIcon(
self.app_instance.action_frame, width=20, height=20, use_pillow=True, bg=bg_color, animation_type=initial_animation_type)
self.app_instance.animated_icon.grid(row=0, column=0, rowspan=2, padx=5)
self.app_instance.animated_icon.grid(
row=0, column=0, rowspan=2, padx=5)
self.app_instance.animated_icon.stop("DISABLE")
self.app_instance.animated_icon.animation_type = backup_animation_type

View File

@@ -272,14 +272,15 @@ class Navigation:
self.app.top_bar.grid()
self._update_task_bar_visibility("settings")
def toggle_backup_content_frame(self, _=None): # Accept argument but ignore it
# Accept argument but ignore it
def toggle_backup_content_frame(self, _=None):
if self.app.refresh_log_var.get():
self.app.log_window.clear_log()
self._cancel_calculation()
self.app.drawing.update_nav_buttons(2) # Index 2 for Backup Content
if not self.app.destination_path:
MessageDialog(master=self.app, message_type="info",
MessageDialog(message_type="info",
title=Msg.STR["info_menu"], text=Msg.STR["err_no_dest_folder"])
self.toggle_mode("backup", 0)
return

View File

@@ -215,7 +215,7 @@ class SchedulerFrame(ttk.Frame):
def _save_job(self):
dest = self.destination.get()
if not dest:
MessageDialog(master=self, message_type="error",
MessageDialog(message_type="error",
title=Msg.STR["error"], text=Msg.STR["err_no_dest_folder"])
return
@@ -227,7 +227,7 @@ class SchedulerFrame(ttk.Frame):
job_sources = [name for name,
var in self.user_sources.items() if var.get()]
if not job_sources:
MessageDialog(master=self, message_type="error",
MessageDialog(message_type="error",
title=Msg.STR["error"], text=Msg.STR["err_no_source_folder"])
return
@@ -290,7 +290,7 @@ class SchedulerFrame(ttk.Frame):
def _remove_selected_job(self):
selected_item = self.jobs_tree.focus()
if not selected_item:
MessageDialog(master=self, message_type="error",
MessageDialog(message_type="error",
title=Msg.STR["error"], text=Msg.STR["err_no_job_selected"])
return

View File

@@ -69,7 +69,7 @@ class SettingsFrame(ttk.Frame):
# --- Hard Reset Frame (initially hidden) ---
self.hard_reset_frame = ttk.LabelFrame(
self, text=Msg.STR["full_delete_config_settings"], padding=10)
hard_reset_label = ttk.Label(
self.hard_reset_frame, text=Msg.STR["hard_reset_warning"], wraplength=400, justify=tk.LEFT)
hard_reset_label.pack(pady=10)
@@ -85,7 +85,6 @@ class SettingsFrame(ttk.Frame):
hard_reset_button_frame, text=Msg.STR["cancel"], command=self._toggle_hard_reset_view)
cancel_hard_reset_button.pack(side=tk.LEFT, padx=5)
# --- Action Buttons ---
self.button_frame = ttk.Frame(self)
self.button_frame.pack(fill=tk.X, padx=10, pady=10)
@@ -130,12 +129,14 @@ class SettingsFrame(ttk.Frame):
def _perform_hard_reset(self):
if self.encryption_manager.mounted_destinations:
dialog = PasswordDialog(self, title=Msg.STR["unlock_backup"], confirm=False, translations=Msg.STR)
dialog = PasswordDialog(
self, title=Msg.STR["unlock_backup"], confirm=False, translations=Msg.STR)
password, _ = dialog.get_password()
if not password:
return
success, message = self.encryption_manager.unmount_all_encrypted_drives(password)
success, message = self.encryption_manager.unmount_all_encrypted_drives(
password)
if not success:
MessageDialog(message_type="error", text=message).show()
return
@@ -152,24 +153,25 @@ class SettingsFrame(ttk.Frame):
if self.hard_reset_visible:
self.trees_container.pack_forget()
self.button_frame.pack_forget()
self.hard_reset_frame.pack(fill=tk.BOTH, expand=True, padx=10, pady=5)
self.hard_reset_frame.pack(
fill=tk.BOTH, expand=True, padx=10, pady=5)
else:
self.hard_reset_frame.pack_forget()
self.trees_container.pack(fill=tk.BOTH, expand=True, padx=10, pady=5)
self.trees_container.pack(
fill=tk.BOTH, expand=True, padx=10, pady=5)
self.button_frame.pack(fill=tk.X, padx=10, pady=10)
def _add_to_exclude_list(self) -> bool:
result = MessageDialog("ask", Msg.STR["exclude_dialog_text"], title=Msg.STR["add_to_exclude_list"], buttons=[
Msg.STR["add_folder_button"], Msg.STR["add_file_button"]]).show()
path = None
if result:
if result == 0: # First button: Folder
dialog = CustomFileDialog(
self, mode="dir", title=Msg.STR["add_to_exclude_list"])
self.wait_window(dialog)
path = dialog.get_result()
dialog.destroy()
else:
elif result == 1: # Second button: File
dialog = CustomFileDialog(
self, filetypes=[("All Files", "*.*")])
self.wait_window(dialog)
@@ -393,4 +395,4 @@ class SettingsFrame(ttk.Frame):
new_tag = "yes" if new_status == Msg.STR["yes"] else "no"
self.hidden_tree.item(item_id, values=(
new_status, current_values[1], current_values[2]), tags=(new_tag,))
new_status, current_values[1], current_values[2]), tags=(new_tag,))

View File

@@ -35,7 +35,8 @@ class SystemBackupContentFrame(ttk.Frame):
def show(self, backup_path, system_backups):
self.backup_path = backup_path
self.system_backups_list = sorted(system_backups, key=lambda b: (b.get('is_encrypted'), b.get('folder_name', '')))
self.system_backups_list = sorted(system_backups, key=lambda b: (
b.get('is_encrypted'), b.get('folder_name', '')))
self._load_backup_content()
def _load_backup_content(self):
@@ -96,7 +97,7 @@ class SystemBackupContentFrame(ttk.Frame):
info_file_path = selected_backup.get('info_file_path')
if not info_file_path or not os.path.isfile(info_file_path):
MessageDialog(self, message_type="error", title="Error",
MessageDialog(message_type="error", title="Error",
text=f"Metadata file not found: {info_file_path}")
return

View File

@@ -38,7 +38,8 @@ class UserBackupContentFrame(ttk.Frame):
def show(self, backup_path, user_backups):
self.backup_path = backup_path
self.user_backups_list = sorted(user_backups, key=lambda b: (b.get('source', ''), b.get('is_encrypted'), b.get('folder_name', '')))
self.user_backups_list = sorted(user_backups, key=lambda b: (
b.get('source', ''), b.get('is_encrypted'), b.get('folder_name', '')))
self._load_backup_content()
def _load_backup_content(self):
@@ -100,7 +101,7 @@ class UserBackupContentFrame(ttk.Frame):
info_file_path = selected_backup.get('info_file_path')
if not info_file_path or not os.path.isfile(info_file_path):
MessageDialog(self, message_type="error", title="Error",
MessageDialog(message_type="error", title="Error",
text=f"Metadata file not found: {info_file_path}")
return
@@ -113,7 +114,7 @@ class UserBackupContentFrame(ttk.Frame):
if not selected_item_id:
return
MessageDialog(master=self, message_type="info",
MessageDialog(message_type="info",
title="Info", text="User restore not implemented yet.")
def _delete_selected(self):