8000 Connect the Animation event source callback in the constructor. by anntzer · Pull Request #26774 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Connect the Animation event source callback in the constructor. #26774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ def __init__(self, fig, event_source=None, blit=False):
# that cause the frame sequence to be iterated.
self.frame_seq = self.new_frame_seq()
self.event_source = event_source
self.event_source.add_callback(self._step)

# Instead of starting the event source now, we connect to the figure's
# draw_event, so that we only start once the figure has been drawn.
Expand Down Expand Up @@ -923,13 +924,9 @@ def _start(self, *args):
return
# First disconnect our draw event handler
self._fig.canvas.mpl_disconnect(self._first_draw_id)

# Now do any initial draw
self._init_draw()

# Add our callback for stepping the animation and
# actually start the event_source.
self.event_source.add_callback(self._step)
# Actually start the event_source.
self.event_source.start()

def _stop(self, *args):
Expand Down
Loading
0