Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ea79bb

Browse files
committed
fix exceptions in qt4 backend with extra mouse buttons
1 parent fbbf5bb commit 4ea79bb

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

lib/matplotlib/backends/backend_qt4.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)