@@ -165,9 +165,10 @@ def mousePressEvent( self, event ):
165165 x = event .pos ().x ()
166166 # flipy so y=0 is bottom of canvas
167167 y = self .figure .bbox .height - event .pos ().y ()
168- button = self .buttond [event .button ()]
169- FigureCanvasBase .button_press_event ( self , x , y , button )
170- if DEBUG : print 'button pressed:' , event .button ()
168+ button = self .buttond .get (event .button ())
169+ if button is not None : # only three buttons supported by MouseEvent
170+ FigureCanvasBase .button_press_event ( self , x , y , button )
171+ if DEBUG : print ('button pressed:' , event .button ())
171172
172173 def mouseMoveEvent ( self , event ):
173174 x = event .x ()
@@ -180,9 +181,10 @@ def mouseReleaseEvent( self, event ):
180181 x = event .x ()
181182 # flipy so y=0 is bottom of canvas
182183 y = self .figure .bbox .height - event .y ()
183- button = self .buttond [event .button ()]
184- FigureCanvasBase .button_release_event ( self , x , y , button )
185- if DEBUG : print 'button released'
184+ button = self .buttond .get (event .button ())
185+ if button is not None : # only three buttons supported by MouseEvent
186+ FigureCanvasBase .button_release_event ( self , x , y , button )
187+ if DEBUG : print ('button released' )
186188
187189 def wheelEvent ( self , event ):
188190 x = event .x ()
0 commit comments