fix: Properly handle widget switching between modes
Issues fixed: 1. Source widget now correctly switches between combobox and listbox 2. Mode changes properly refresh and show correct source options 3. Added better logging to track widget switches 4. Clear selections when switching modes 5. Force UI update after widget changes Now: - LV modes (lv_to_borg, files_to_borg) show multi-select listbox - VG modes (vg_to_borg) show single-select combobox - Widget switching works correctly when changing modes - Borg settings appear for all Borg modes
This commit is contained in:
@@ -23,7 +23,7 @@ class SimpleBackupGUI:
|
||||
self.current_snapshot = None
|
||||
|
||||
self.setup_ui()
|
||||
self.refresh_drives()
|
||||
self.refresh_drives() # Initialize with correct widgets for default mode
|
||||
|
||||
def setup_ui(self):
|
||||
# Main frame
|
||||
@@ -197,12 +197,11 @@ class SimpleBackupGUI:
|
||||
# Show/hide Borg settings
|
||||
if mode in ["lv_to_borg", "vg_to_borg", "files_to_borg"]:
|
||||
self.borg_frame.grid()
|
||||
# Clear target combo for Borg modes (repo path is used instead)
|
||||
self.target_combo['values'] = []
|
||||
self.target_var.set("")
|
||||
else:
|
||||
self.borg_frame.grid_remove()
|
||||
self.refresh_drives()
|
||||
|
||||
# Always refresh drives when mode changes
|
||||
self.refresh_drives()
|
||||
|
||||
def log(self, message):
|
||||
"""Add message to log"""
|
||||
@@ -258,15 +257,25 @@ class SimpleBackupGUI:
|
||||
mode = self.mode_var.get()
|
||||
self.log(f"Refreshing drives for mode: {mode}")
|
||||
|
||||
# Clear target combo for Borg modes
|
||||
if mode in ["lv_to_borg", "vg_to_borg", "files_to_borg"]:
|
||||
self.target_combo['values'] = []
|
||||
self.target_var.set("")
|
||||
|
||||
# Show appropriate source selection widget
|
||||
if mode in ["lv_to_borg", "files_to_borg"]:
|
||||
# Multi-selection for LV modes
|
||||
# Multi-selection for individual LV modes
|
||||
self.source_combo.grid_remove()
|
||||
self.source_listbox_frame.grid(row=0, column=0, sticky=(tk.W, tk.E, tk.N, tk.S))
|
||||
self.log("Switched to multi-selection listbox for LV selection")
|
||||
else:
|
||||
# Single selection for other modes
|
||||
# Single selection for VG modes and other modes
|
||||
self.source_listbox_frame.grid_remove()
|
||||
self.source_combo.grid(row=0, column=0, sticky=(tk.W, tk.E))
|
||||
self.log("Switched to single-selection combobox")
|
||||
|
||||
# Update the window to force widget refresh
|
||||
self.root.update_idletasks()
|
||||
|
||||
# Source options
|
||||
if mode == "vg_to_raw" or mode == "vg_to_borg":
|
||||
@@ -284,6 +293,7 @@ class SimpleBackupGUI:
|
||||
source_list.append(f"{vg_name} ({vg_size}) [{pv_count} PVs]")
|
||||
|
||||
self.source_combo['values'] = source_list
|
||||
self.source_var.set("") # Clear selection
|
||||
self.log(f"Found {len(source_list)} volume groups")
|
||||
else:
|
||||
self.log("No volume groups found")
|
||||
@@ -302,13 +312,18 @@ class SimpleBackupGUI:
|
||||
vg_name = parts[2]
|
||||
lv_list.append(f"{lv_path} ({lv_size}) [VG: {vg_name}]")
|
||||
|
||||
# Update both single and multi-selection widgets
|
||||
# Update the appropriate widget
|
||||
if mode in ["lv_to_borg", "files_to_borg"]:
|
||||
# Update listbox for multi-selection
|
||||
self.source_listbox.delete(0, tk.END)
|
||||
for lv in lv_list:
|
||||
self.source_listbox.insert(tk.END, lv)
|
||||
self.log(f"Loaded {len(lv_list)} logical volumes into listbox")
|
||||
else:
|
||||
# Update combobox for single selection
|
||||
self.source_combo['values'] = lv_list
|
||||
self.source_var.set("") # Clear selection
|
||||
self.log(f"Loaded {len(lv_list)} logical volumes into combobox")
|
||||
|
||||
self.log(f"Found {len(lv_list)} logical volumes")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user