I'm running the Qt4 backend, and I noticed that I'd frequently get error 
messages saying I was pressing unrecognized keys. It turns out that the 
direction keys aren't recognized in the qt4 backend. (I'm using direction keys 
to switch between spaces in OSX, so this error gets triggered quite frequently)

One possible fix is to just add the direction keys to the list of valid keys 
(see patch below). Alternatively, the key event code could just ignore 
unrecognized keys (i.e. `key == None`). This change could be made in 
FigureCanvasQT.keyPressEvent (in backends.backend_qt4.py) or, more generally, 
in FigureCanvasBase.key_press_event (in backend_bases.py).

-Tony

%---Diff

Index: lib/matplotlib/backends/backend_qt4.py
===================================================================
--- lib/matplotlib/backends/backend_qt4.py      (revision 8315)
+++ lib/matplotlib/backends/backend_qt4.py      (working copy)
@@ -129,6 +129,10 @@
     keyvald = { QtCore.Qt.Key_Control : 'control',
                 QtCore.Qt.Key_Shift : 'shift',
                 QtCore.Qt.Key_Alt : 'alt',
+                QtCore.Qt.Key_Up : 'up',
+                QtCore.Qt.Key_Right : 'right',
+                QtCore.Qt.Key_Down : 'down',
+                QtCore.Qt.Key_Left : 'left',
                }
     # left 1, middle 2, right 3
     buttond = {1:1, 2:3, 4:2}


%---Full traceback

Traceback (most recent call last):
  File "/Users/Tony/python/devel/mpl/lib/matplotlib/backends/backend_qt4.py", 
line 198, in keyPressEvent
    FigureCanvasBase.key_press_event( self, key )
  File "/Users/Tony/python/devel/mpl/lib/matplotlib/backend_bases.py", line 
1459, in key_press_event
    self.callbacks.process(s, event)
  File "/Users/Tony/python/devel/mpl/lib/matplotlib/cbook.py", line 169, in 
process
    func(*args, **kwargs)
  File "/Users/Tony/python/devel/mpl/lib/matplotlib/backend_bases.py", line 
2079, in key_press
    if event.key in fullscreen_keys:
TypeError: 'in <string>' requires string as left operand, not NoneType


------------------------------------------------------------------------------

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to