Skip to content

Commit

Permalink
FEATURE: Add why and why_now tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
amilcarlucas committed Dec 31, 2024
1 parent 3134f1a commit 16a52ed
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 16a52ed

Please sign in to comment.