diff --git a/ardupilot_methodic_configurator/backend_filesystem_configuration_steps.py b/ardupilot_methodic_configurator/backend_filesystem_configuration_steps.py index 5a85914..3a48a68 100644 --- a/ardupilot_methodic_configurator/backend_filesystem_configuration_steps.py +++ b/ardupilot_methodic_configurator/backend_filesystem_configuration_steps.py @@ -201,3 +201,16 @@ def get_documentation_text_and_url(self, selected_file: str, prefix_key: str) -> text = documentation.get(prefix_key + "_text", text.format(**locals())) url = documentation.get(prefix_key + "_url", "") return text, url + + def get_seq_tooltip_text(self, selected_file: str, tooltip_key: str) -> str: + documentation = self.configuration_steps.get(selected_file, {}) if self.configuration_steps else None + if documentation is None: + text = _( + "File '{self.configuration_steps_filename}' not found. " + "No intermediate parameter configuration steps available" + ) + text = text.format(**locals()) + else: + text = _("No documentation available for {selected_file} in the {self.configuration_steps_filename} file") + text = documentation.get(tooltip_key, text.format(**locals())) + return text diff --git a/ardupilot_methodic_configurator/frontend_tkinter_parameter_editor.py b/ardupilot_methodic_configurator/frontend_tkinter_parameter_editor.py index 387086f..a6eabdb 100755 --- a/ardupilot_methodic_configurator/frontend_tkinter_parameter_editor.py +++ b/ardupilot_methodic_configurator/frontend_tkinter_parameter_editor.py @@ -505,6 +505,7 @@ def on_param_file_combobox_change(self, _event: Union[None, tk.Event], forced: b self.current_file = selected_file self.at_least_one_changed_parameter_written = False self.documentation_frame.update_documentation_labels(selected_file) + self.documentation_frame.update_why_why_now_tooltip(selected_file) self.repopulate_parameter_table(selected_file) def download_flight_controller_parameters(self, redownload: bool = False) -> None: diff --git a/ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_documentation_frame.py b/ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_documentation_frame.py index ac82913..7f47c4b 100644 --- a/ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_documentation_frame.py +++ b/ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_documentation_frame.py @@ -21,7 +21,7 @@ from ardupilot_methodic_configurator.frontend_tkinter_base import show_tooltip -class DocumentationFrame: # pylint: disable=too-few-public-methods +class DocumentationFrame: """ A class to manage and display documentation within the GUI. @@ -93,6 +93,18 @@ def __create_documentation_frame(self) -> None: # Dynamically update the documentation text and URL links self.update_documentation_labels(self.current_file) + self.update_why_why_now_tooltip(self.current_file) + + def update_why_why_now_tooltip(self, current_file: str) -> None: + why_tooltip_text = self.local_filesystem.get_seq_tooltip_text(current_file, "why") + why_now_tooltip_text = self.local_filesystem.get_seq_tooltip_text(current_file, "why_now") + tooltip_text = "" + if why_tooltip_text: + tooltip_text += _("Why: ") + why_tooltip_text + "\n" + if why_now_tooltip_text: + tooltip_text += _("Why now: ") + why_now_tooltip_text + if tooltip_text: + show_tooltip(self.documentation_frame, tooltip_text) def update_documentation_labels(self, current_file: str) -> None: self.current_file = current_file