Skip to content

Commit 24897f7

Browse files
committed
fix(param editor): update the change reason tooltip when the param value changes
1 parent 73d3e2a commit 24897f7

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_table.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def __create_new_value_entry( # pylint: disable=too-many-arguments, too-many-po
379379
)
380380

381381
# Function to show the appropriate error message
382-
def show_parameter_error(_event: tk.Event) -> None: # pylint: disable=unused-argument
382+
def show_parameter_error(_event: tk.Event) -> None:
383383
if present_as_forced:
384384
messagebox.showerror(_("Forced Parameter"), forced_error_msg)
385385
elif present_as_derived:
@@ -690,6 +690,30 @@ def __on_parameter_value_change(self, event: tk.Event, current_file: str, param_
690690
# Revert to the previous (valid) value
691691
p = old_value
692692
self.__update_new_value_entry_text(event.widget, p, self.local_filesystem.param_default_dict.get(param_name, None))
693+
self.__update_change_reason_entry_tooltip(param_name, p)
694+
695+
def __update_change_reason_entry_tooltip(self, param_name: str, param_value: float) -> None:
696+
"""Update the tooltip on the change reason entry with the current parameter value."""
697+
value_str = format(param_value, ".6f").rstrip("0").rstrip(".")
698+
699+
# Find the change reason entry widget for this parameter
700+
for widget in self.view_port.winfo_children():
701+
if isinstance(widget, ttk.Entry) and widget.grid_info().get("column", 0) == 6:
702+
# Get the parameter label in the same row
703+
row = widget.grid_info().get("row")
704+
for param_widget in self.view_port.winfo_children():
705+
if (
706+
isinstance(param_widget, ttk.Label)
707+
and param_widget.grid_info().get("column", 0) == 1
708+
and param_widget.grid_info().get("row") == row
709+
and param_widget.cget("text").strip() == param_name
710+
):
711+
# Found the matching change reason entry, update its tooltip
712+
msg = _("Reason why {param_name} should change to {value_str}")
713+
show_tooltip(widget, msg.format(**locals()))
714+
return
715+
716+
logging_debug(_("Could not find change reason entry widget for parameter %s (%s)"), param_name, value_str)
693717

694718
def __on_parameter_change_reason_change(self, event: tk.Event, current_file: str, param_name: str) -> None:
695719
# Get the new value from the Entry widget

0 commit comments

Comments
 (0)