Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
Bug summary
Pressing keypad numbers do not report keys correctly under tkagg+linux, if numlock is active (i.e. when numbers should be reported); numbers are incorrectly reported when numlock is inactive (i.e. when numbers shouldnot be reported).
Code for reproduction
MPLBACKEND=tkagg python -c 'from pylab import *; gcf().canvas.mpl_connect("key_press_event", lambda event: print(event.key)); show()'
Actual outcome
numbers are printed when numlock is inactive, and vice versa.
Expected outcome
the opposite
Matplotlib version
- Operating system: ubuntu
- Matplotlib version: 2.0.2 (but likely irrelevant
- Matplotlib backend (
print(matplotlib.get_backend())
): tkagg - Python version: 3.6
- Jupyter version (if applicable):
- Other libraries:
This is due to FigureCanvasTkAgg.keyvald using incorrect values for the mapping: it uses the values athttp://infohost.nmt.edu/tcc/help/pubs/tkinter/web/key-names.html (KP_0, etc.) but the correct values (in the tk sources themselves...) are athttps://github.com/tcltk/tk/blame/a1577313301d5ad9a6e553b359f7e5de2b8f6153/generic/ks_names.h (themselves derived fromhttps://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h) and suggests that the numlock state got inverted.
On Windows this is irrelevant, keypad presses are reported with a keyval_sym <256 and thus directly converted via ASCII to the correct value. Not sure about the situation under OSX.