In this post, we will see how to resolve is there a way to change the keys to navigate the tkinter MenuButton options in python?
Question:
The opening of the menu in the Menubutton widget seems to block any key input aside from the arrow keys, the enter key and the escape key.I’m trying to assign the function of the enter key in that scenario to another key, but it seems impossible.
I wonder if there’s any way to make that possible and, if not, if any of you can point me to any “homemade” class that could replace the menubutton entirely (except for that flaw).
Thanks in advance for your attention.
[I’ve tried binding the apparent functionality of those keys (arrows, enter and scape) to other keys; I’ve tried to find out where the commands of those keys were rooted for them to be able to work in that scenario; I’ve tried to unbind the functionality of those keys to see if I could find out how they were working; and I tried to make my own similar Menubutton class (with blackjack and hookers). I have miserably failed at all those tasks.]
Here’s a small example of the problem:
Best Answer:
peputito, it’s me, you, from the near future.I might have found a way around your problem that could help people all around the world in this exact same situation.
First, I want to clarify that I have not yet found why the problem occurs (it still seems to me that, once a menubutton is posted, no key on the keyboard, besides the arrow keys, the return and the escape, is able to work).
BUT, I have come up with a very un-elegant solution that does what you want to achieve:
As said, it is not very elegant (if I think that means what I think that means), but it does the trick for the both of us.
Cheers, peputito from the past.
EDIT: Also, since a lot of my menubutton options are shown as acronyms when selected (for space reasons), I’ve created a way to show a tooltip each time I pick an option without posting the full cascade (in the cascade you could see the full option instead of the acronym).
If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com