How to get arrow keys and enter key on keyboard in Linux to behave like windows7

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() 
+6
source share
1 answer

With this script (from here ), it should be easy to identify the key event triggered by Tkinter when you press any key, be it <Return> , <KP_Enter> , or (somehow, maybe your keyboard has a funny display) that something else.

Just look at the console output when you press the right button, and use this key event in your actual code.

 import Tkinter def callback(e): print e.keysym w = Tkinter.Frame(width=512, height=512) w.bind("<KeyPress>", callback) w.focus_set() w.pack() w.mainloop() 
0
source

All Articles