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

Skip to content

Commit ddf2c57

Browse files
committed
Merge pull request matplotlib#1944 from mdboom/cancel-zoom
ValueError exception in drag_zoom (tk backend)
2 parents b0259b3 + fcfd408 commit ddf2c57

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2863,6 +2863,18 @@ def press_pan(self, event):
28632863

28642864
def press_zoom(self, event):
28652865
"""the press mouse button in zoom to rect mode callback"""
2866+
# If we're already in the middle of a zoom, pressing another
2867+
# button works to "cancel"
2868+
if self._ids_zoom != []:
2869+
for zoom_id in self._ids_zoom:
2870+
self.canvas.mpl_disconnect(zoom_id)
2871+
self.release(event)
2872+
self.draw()
2873+
self._xypress = None
2874+
self._button_pressed = None
2875+
self._ids_zoom = []
2876+
return
2877+
28662878
if event.button == 1:
28672879
self._button_pressed = 1
28682880
elif event.button == 3:

0 commit comments

Comments
 (0)