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:
import tkinter as tk
def option1():
print("You've chosen option 1")
def option2():
print("You've chosen option 2")
def option3():
print("You've chosen option 3")
def SomethingSomething(event):
event.widget.event_generate('<Return>')
root = tk.Tk()
root.geometry("200x200")
options = ["Option 1", "Option 2", "Option 3"]
var = tk.StringVar(root)
var.set(options[0])
mb = tk.Menubutton(root, text="Select an option", relief="raised", width=20)
mb.menu = tk.Menu(mb, tearoff=0)
mb["menu"] = mb.menu
for option in options:
mb.menu.add_radiobutton(label=option, variable=var, value=option, command=eval("option" + str(options.index(option) + 1)))
mb.pack()
mb.bind('<Control-Key-5>', SomethingSomething)
root.mainloop()