From 6da0dea2a5db67d550c78fc0a4452f2e97299acb Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Thu, 21 Aug 2025 14:26:19 -0500 Subject: [PATCH] Disabled file browse buttons until a device is sucessfully connected --- src/gui/main_window.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/gui/main_window.py b/src/gui/main_window.py index c610777..bc9ee5c 100644 --- a/src/gui/main_window.py +++ b/src/gui/main_window.py @@ -108,9 +108,10 @@ class AndroidFileHandlerGUI(tk.Tk): anchor="w" ) self.remote_path_display.pack(side="left", fill="x", expand=True) - tk.Button( + self.remote_browse_btn = tk.Button( android_path_frame, text="Browse...", command=self.browse_remote_folder - ).pack(side="right", padx=(5, 0)) + ) + self.remote_browse_btn.pack(side="right", padx=(5, 0)) # Create the Computer path section self.computer_frame = tk.Frame(self.path_container) @@ -126,9 +127,10 @@ class AndroidFileHandlerGUI(tk.Tk): anchor="w" ) self.local_path_display.pack(side="left", fill="x", expand=True) - tk.Button( + self.local_browse_btn = tk.Button( computer_path_frame, text="Browse...", command=self.browse_local_folder - ).pack(side="right", padx=(5, 0)) + ) + self.local_browse_btn.pack(side="right", padx=(5, 0)) # Initially arrange for pull (Android on top) self._arrange_path_sections() @@ -143,6 +145,9 @@ class AndroidFileHandlerGUI(tk.Tk): ) self.start_btn.pack(pady=10) + # Initially disable browse buttons until device is connected + self._disable_browse_buttons() + # Window close protocol self.protocol("WM_DELETE_WINDOW", self.on_close) @@ -202,6 +207,16 @@ class AndroidFileHandlerGUI(tk.Tk): if self.start_btn.cget("text") == "Start Transfer": self.start_btn.config(state="disabled") + def _enable_browse_buttons(self): + """Enable both browse buttons when device is connected.""" + self.remote_browse_btn.config(state="normal") + self.local_browse_btn.config(state="normal") + + def _disable_browse_buttons(self): + """Disable both browse buttons when no device is detected.""" + self.remote_browse_btn.config(state="disabled") + self.local_browse_btn.config(state="disabled") + def _start_transfer_animation(self): """Start the 'Transferring...' animation.""" print("[DEBUG] Starting transfer animation") @@ -259,6 +274,7 @@ class AndroidFileHandlerGUI(tk.Tk): if not device: self.device_connected = False self.disable_controls() + self._disable_browse_buttons() self._update_status( "No device detected. Enable USB debugging and connect your device." ) @@ -266,6 +282,7 @@ class AndroidFileHandlerGUI(tk.Tk): self.show_enable_debugging_instructions() else: self.device_connected = True + self._enable_browse_buttons() self._update_status(f"Device detected: {device}") self._switch_to_transfer_mode() self.enable_controls()