@@ -156,6 +156,8 @@ class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ):
156156 (QtCore .Qt .ControlModifier , 'ctrl' , QtCore .Qt .Key_Control )
157157 ]
158158
159+ _ctrl_modifier = QtCore .Qt .ControlModifier
160+
159161 if sys .platform == 'darwin' :
160162 # in OSX, the control and super (aka cmd/apple) keys are switched, so
161163 # switch them back.
@@ -169,15 +171,17 @@ class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ):
169171 (QtCore .Qt .AltModifier , 'alt' , QtCore .Qt .Key_Alt ),
170172 (QtCore .Qt .MetaModifier , 'ctrl' , QtCore .Qt .Key_Meta ),
171173 ]
172-
174+
175+ _ctrl_modifier = QtCore .Qt .MetaModifier
176+
173177 # map Qt button codes to MouseEvent's ones:
174178 buttond = {QtCore .Qt .LeftButton : 1 ,
175179 QtCore .Qt .MidButton : 2 ,
176180 QtCore .Qt .RightButton : 3 ,
177181 # QtCore.Qt.XButton1 : None,
178182 # QtCore.Qt.XButton2 : None,
179183 }
180-
184+
181185 def __init__ ( self , figure ):
182186 if DEBUG : print ('FigureCanvasQt: ' , figure )
183187 _create_qApp ()
@@ -299,16 +303,15 @@ def _get_key( self, event ):
299303
300304 if event .key () < 256 :
301305 key = unicode (event .text ())
302-
303306 # if the control key is being pressed, we don't get the correct
304307 # characters, so interpret them directly from the event.key().
305308 # Unfortunately, this means that we cannot handle key's case
306- # since event.key() is not case sensitve , whereas event.text() is,
309+ # since event.key() is not case sensitive , whereas event.text() is,
307310 # Finally, since it is not possible to get the CapsLock state
308311 # we cannot accurately compute the case of a pressed key when
309312 # ctrl+shift+p is pressed.
310- if int (event .modifiers ()) & QtCore . Qt . ControlModifier :
311- # we always get an uppercase charater
313+ if int (event .modifiers ()) & self . _ctrl_modifier :
314+ # we always get an uppercase character
312315 key = chr (event .key ())
313316 # if shift is not being pressed, lowercase it (as mentioned,
314317 # this does not take into account the CapsLock state)
@@ -322,7 +325,7 @@ def _get_key( self, event ):
322325 # prepend the ctrl, alt, super keys if appropriate (sorted in that order)
323326 for modifier , prefix , Qt_key in self ._modifier_keys :
324327 if event .key () != Qt_key and int (event .modifiers ()) & modifier == modifier :
325- key = '{}+{}' .format (prefix , key )
328+ key = u '{}+{}' .format (prefix , key )
326329
327330 return key
328331
0 commit comments