Closed robertmlinden closed 6 years ago
Interesting one... the code across the menu widgets is all fairly generic.
The accelerator (shortcut) & function are passed straight to the tkinter function that creates the checkbox - this links the function to the action of clicking the menu item, and displays the shortcut alongside it.
There is then a separate piece of code that binds the shortcut to the function - which seems to have been causing you some issues already!
There's obviously a gap here - the binding is triggering the function, rather than triggering the menu
So, you could use: .setMenuCheckBox(menu, name)
& .getMenuCheckBox(menu, name)
to toggle the menu when your function is called (although you might need to set a flag so that toggling the checkbox doesn't run your function again!)
But, it should be toggled automatically....
I think the code will need to be changed, so that an internal function is associated with checkboxes, that first toggles the checkbox, before then calling the user's function.
Just tested this on the Pi - including the line .setMenuCheckBox(menu, name)
in your function will toggle the checkbox, and doesn't trigger the function again - result!
That did the trick, thanks for all the hlp!
@robertmlinden - actually, playing with this some more this morning, it fixes the keyboard shortcut, but breaks simply clicking the menu item - as it now gets toggled twice.
I've pushed a fix into next_release which fixes it for all, so you won't need to add any extra code to get it to work...
Metainformation: appJar 0.93 Python 3.6 Windows 10