diff --git a/ardupilot_methodic_configurator/frontend_tkinter_base_window.py b/ardupilot_methodic_configurator/frontend_tkinter_base_window.py index d5c5e2682..7fb0bdc61 100644 --- a/ardupilot_methodic_configurator/frontend_tkinter_base_window.py +++ b/ardupilot_methodic_configurator/frontend_tkinter_base_window.py @@ -140,7 +140,8 @@ def _setup_application_icon(self) -> None: # https://pythonassets.com/posts/window-icon-in-tk-tkinter/ try: icon_path = ProgramSettings.application_icon_filepath() - self.root.iconphoto(True, tk.PhotoImage(file=icon_path)) # noqa: FBT003 + self._icon_photo = tk.PhotoImage(master=self.root, file=icon_path) + self.root.iconphoto(True, self._icon_photo) # noqa: FBT003 except (tk.TclError, FileNotFoundError) as e: # Silently ignore icon loading errors (common in test environments) logging_error(_("Could not load application icon: %s"), e) @@ -524,7 +525,7 @@ def put_image_in_label( # pylint: disable=too-many-locals buffer.seek(0) # Create PhotoImage from buffer - photo = tk.PhotoImage(data=buffer.getvalue()) + photo = tk.PhotoImage(master=parent, data=buffer.getvalue()) if is_debugging(): return ttk.Label(parent) # the vscode debugger can not cope with the images diff --git a/ardupilot_methodic_configurator/frontend_tkinter_project_creator.py b/ardupilot_methodic_configurator/frontend_tkinter_project_creator.py index 07cfbe79d..9f8da50c8 100755 --- a/ardupilot_methodic_configurator/frontend_tkinter_project_creator.py +++ b/ardupilot_methodic_configurator/frontend_tkinter_project_creator.py @@ -92,7 +92,7 @@ def create_option1_widgets( # pylint: disable=too-many-locals,too-many-argument connected_fc_vehicle_type: str, ) -> None: # Option 1 - Create a new vehicle configuration directory based on an existing template - option1_label = ttk.Label(text=_("New vehicle"), style="Bold.TLabel") + option1_label = ttk.Label(self.main_frame, text=_("New vehicle"), style="Bold.TLabel") option1_label_frame = ttk.LabelFrame(self.main_frame, labelwidget=option1_label) option1_label_frame.pack(expand=True, fill=tk.X, padx=6, pady=6) template_dir_edit_tooltip = _( diff --git a/ardupilot_methodic_configurator/frontend_tkinter_project_opener.py b/ardupilot_methodic_configurator/frontend_tkinter_project_opener.py index 4f8e98dd4..09b5315c3 100755 --- a/ardupilot_methodic_configurator/frontend_tkinter_project_opener.py +++ b/ardupilot_methodic_configurator/frontend_tkinter_project_opener.py @@ -82,7 +82,7 @@ def close_and_quit(self) -> None: def create_option1_widgets(self) -> None: # Option 1 - Create a new vehicle configuration directory based on an existing template - option1_label = ttk.Label(text=_("New vehicle"), style="Bold.TLabel") + option1_label = ttk.Label(self.main_frame, text=_("New vehicle"), style="Bold.TLabel") option1_label_frame = ttk.LabelFrame(self.main_frame, labelwidget=option1_label) option1_label_frame.pack(expand=True, fill=tk.X, padx=6, pady=6) @@ -112,7 +112,7 @@ def on_bin_log_selected(bin_file: str) -> None: def create_option2_widgets(self, initial_dir: str) -> None: # Option 2 - Use an existing vehicle configuration directory - option2_label = ttk.Label(text=_("Open vehicle"), style="Bold.TLabel") + option2_label = ttk.Label(self.main_frame, text=_("Open vehicle"), style="Bold.TLabel") option2_label_frame = ttk.LabelFrame(self.main_frame, labelwidget=option2_label) option2_label_frame.pack(expand=True, fill=tk.X, padx=6, pady=6) option2_label = ttk.Label( @@ -140,7 +140,7 @@ def on_vehicle_directory_selected(directory: str) -> None: def create_option3_widgets(self) -> None: # Option 3 - Open the last used vehicle configuration directory - option3_label = ttk.Label(text=_("Re-Open vehicle"), style="Bold.TLabel") + option3_label = ttk.Label(self.main_frame, text=_("Re-Open vehicle"), style="Bold.TLabel") option3_label_frame = ttk.LabelFrame(self.main_frame, labelwidget=option3_label) option3_label_frame.pack(expand=True, fill=tk.X, padx=6, pady=6) diff --git a/tests/test_frontend_tkinter_base_window.py b/tests/test_frontend_tkinter_base_window.py index 6bdaede56..872f79960 100755 --- a/tests/test_frontend_tkinter_base_window.py +++ b/tests/test_frontend_tkinter_base_window.py @@ -301,7 +301,7 @@ def test_user_sees_properly_sized_images(self, image_test_context, sample_image_ mocks["open_mock"].assert_called_once_with(sample_image_file) mocks["image"].resize.assert_called_once() # Check that PhotoImage was called with data parameter (our new implementation) - mocks["photo_mock"].assert_called_once_with(data=b"fake_png_data") + mocks["photo_mock"].assert_called_once_with(master=parent_frame, data=b"fake_png_data") def test_user_sees_fallback_when_image_unavailable(self, image_test_context, mocked_base_window) -> None: """