tkinter keypress events are a mess for numpad keys

Irmen de Jong irmen.NOSPAM at xs4all.nl
Mon Aug 28 19:20:18 EDT 2017


Hi,

Using tkinter in python3, I was trying to intercept individual keypresses (and releases)
of keys on the numeric keypad. I want to use this as a simple joystick simulation.
While you can bind the <KeyPress> event, actually doing something sensible with it in a
cross platform way seems utterly impossible.

The distinguishing attribute of the event object is different depending on what OS
you're using (keysym, keycode, keysym_num) and on Windows registering some keys doesn't
even seem to work (or they're confused with the same keys on the normal keyboard area).
The keysym names/values in the documentation are not correct either
(I'm mainly looking at http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/key-names.html)


My original question with the details on stackoverflow:
https://stackoverflow.com/questions/45869902/better-way-to-deal-with-tks-keyboard-events-mess-for-numpad-keys-in-pythontkin

Unfortunately there hasn't been a useful response or answer.

A gist with a small example program is here:
https://gist.github.com/irmen/2c9d6bb0afb16b464805410c108a2885

Does anyone here have a clue perhaps?
Or have any idea why this is so messy?


Thank you!
Irmen



More information about the Python-list mailing list