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

Skip to content

Commit df926b7

Browse files
FIX: Animation shouldn't start by itself after resizing window
If event_source was stopped, it should remain stopped after resize event
1 parent dc0328f commit df926b7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/animation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,7 @@ def _on_resize(self, event):
12001200
# we're paused. Reset the cache and re-init. Set up an event handler
12011201
# to catch once the draw has actually taken place.
12021202
self._fig.canvas.mpl_disconnect(self._resize_id)
1203+
self._was_stopped = self.event_source._timer is None
12031204
self.event_source.stop()
12041205
self._blit_cache.clear()
12051206
self._init_draw()
@@ -1209,8 +1210,9 @@ def _on_resize(self, event):
12091210
def _end_redraw(self, event):
12101211
# Now that the redraw has happened, do the post draw flushing and
12111212
# blit handling. Then re-enable all of the original events.
1212-
self._post_draw(None, False)
1213-
self.event_source.start()
1213+
self._post_draw(None, self._blit)
1214+
if not self._was_stopped:
1215+
self.event_source.start()
12141216
self._fig.canvas.mpl_disconnect(self._resize_id)
12151217
self._resize_id = self._fig.canvas.mpl_connect('resize_event',
12161218
self._on_resize)

0 commit comments

Comments
 (0)