Fernando Perez :
This happens also with different backends and the driving
interface (say, Idle with Tkinter...)
The lack of a clean pause/restart
functionality is indeed problematic. Furthermore, closing a window
that's running an animation, at least with the Qt backend, gave rise
to a massive swarm of 'C++ object has been deleted' messages flooding
the console where my ipython kernel had been started.
Some solutions exist. The simplest one is the following.
1. Use a particular event source, e.g. launch:
ani = anima.FuncAnimation(fig, proc, repeat=False,
Include a button
while running: yield 0 #or whatever
and it will kill your animation in a proper way. Restarting it
demands that "ani" be recreated within a callback, say, a startbutton.
But this is not pausing. Recreating the animation, recreating and
starting a timer, connecting all the callbacks... this takes time,
and you SEE it.
if you go down the road of implementing a
full-blown event loop for matplotlib, is how well it will play with
existing event loops. Whenever an interactive GUI backend is running,
there's already an event loop at work: that of the GUI toolkit.
Integrating multiple event loops in the same process takes some
delicate footwork if you don't want to end up with a nasty fight
between the two.
But first, you don't need to launch show() and force some
mainloop(), MainLoop(), gtk.main(), etc. under the hood. We wrote
some loops under wx, simple-minded ; there is one included in the
standard docs-and-demos. I don't know yet how to force WindowUpdate
from Matplotlib, but some "plugin" solution should exist, since
Matplotlib does that already.
Second, even if an event loop runs already, the question is to plug
in the access to the concrete event queue mechanism, not to
superpose another one, and yell with horror at which level declare
Thank you, Fernando.