Python : How to bind tkinter widget to numeric enter key
I'm creating a simple python program and I need to bind my tkinter widget to the right enter key (the one which is located in the keyboard numeric pad)
I've browsed google and found the <Return> key binding but it works only for the main enter key. I really need it because my users will use the numeric keypad for the main operation. Thanks for any help |
Have not tried using it in Python, but xev shows keysym 0xff0d for the return key by the alpha keys, and 0xff8d for the keypad return key
|
The key is called KP_Enter. See this reference:
http://infohost.nmt.edu/tcc/help/pub...key-names.html (found by googling "python tkinter bind numeric return" The table contains much more that may interest you.) |
It's also KP_Enter according to xev:
Code:
KeyRelease event, serial 36, synthetic NO, window 0x1e00001, |
Besides looking it up online, another way to discover the name of the key is to inspect the event.keysym attribute in the event handler. Here is a Python 2 program which works for almost any key pressed:
Code:
from Tkinter import * Code:
$ python2 keypress.py |
It works well with KP_Enter. I'll learn about xev soon.
Thanks for everybody. |
All times are GMT -5. The time now is 04:43 PM. |