I am developing a program for controlling a machine to which only a keyboard will be connected. I am using Python 2.7 and Tkinter 8.5 . I use OptionMenu to allow the user to configure on the machine.
When I am running Windows, I can use the arrow keys on the keyboard to navigate the drop-down list, and then use the keyboard input to select an option. This does not work on Linux (Debian Wheezy).
How to associate KP_Enter with a return key?
import Tkinter def c(self, event): event.b[".keysym"] = "<<space>>" print "button invoked" t = Tkinter.Tk() b = Tkinter.OptionMenu(t, ".500", ".510", ".520", ".550", ".560", ".570", ".580", command=c) t.bind("<KP_Enter>", c) e = Tkinter.Entry() e.pack() b.pack(anchor=Tkinter.E) t.mainloop()
source share