Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: allow editing bitmask values numerically #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,17 @@
new_value_entry.config(state="disabled", background="light grey")
elif bitmask_dict:
new_value_entry.bind(
"<FocusIn>", lambda event: self.__open_bitmask_selection_window(event, param_name, bitmask_dict, old_value)
"<Double-Button>",
lambda event: self.__open_bitmask_selection_window(event, param_name, bitmask_dict, old_value),
)
# pylint: disable=line-too-long
new_value_entry.bind(
"<FocusOut>",
lambda event, current_file=self.current_file, param_name=param_name: self.__on_parameter_value_change( # type: ignore[misc]
event, current_file, param_name
),
)
# pylint: enable=line-too-long
else:
# pylint: disable=line-too-long
new_value_entry.bind(
Expand Down Expand Up @@ -414,9 +423,14 @@
self.root.update_idletasks()
# Re-bind the FocusIn event to new_value_entry
event.widget.bind(
"<FocusIn>", lambda event: self.__open_bitmask_selection_window(event, param_name, bitmask_dict, old_value)
"<Double-Button>",
lambda event: self.__open_bitmask_selection_window(event, param_name, bitmask_dict, old_value),
)

def focus_out_handler(event: tk.Event) -> None:

Check failure on line 430 in ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_table.py

View workflow job for this annotation

GitHub Actions / ruff (py39)

Ruff (ARG001)

ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_table.py:430:31: ARG001 Unused function argument: `event`
if not window.focus_get() or not window.focus_get().winfo_ismapped():

Check failure on line 431 in ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_table.py

View workflow job for this annotation

GitHub Actions / mypy

ardupilot_methodic_configurator/frontend_tkinter_parameter_editor_table.py#L431

[error] Item
on_close()

def get_param_value_msg(_param_name: str, checked_keys: set) -> str:
_new_decimal_value = sum(1 << key for key in checked_keys)
text = _("{_param_name} Value: {_new_decimal_value}")
Expand All @@ -427,7 +441,7 @@
close_label.config(text=get_param_value_msg(param_name, checked_keys))

# Temporarily unbind the FocusIn event to prevent triggering the window again
event.widget.unbind("<FocusIn>")
event.widget.unbind("<Double-Button>")
window = tk.Toplevel(self.root)
title = _("Select {param_name} Bitmask Options")
window.title(title.format(**locals()))
Expand All @@ -452,6 +466,9 @@

# Bind the on_close function to the window's WM_DELETE_WINDOW protocol
window.protocol("WM_DELETE_WINDOW", on_close)
window.bind("<FocusOut>", focus_out_handler)
for child in window.winfo_children():
child.bind("<FocusOut>", focus_out_handler)

# Make sure the window is visible before disabling the parent window
window.deiconify()
Expand Down
Loading