Fernando Perez :
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.
This happens also with different backends and the driving interface (say, Idle with Tkinter...)
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, frames=sourcegen)


where

   def sourcegen():
        while running: yield 0 #or whatever
        return

Include a button

   def astop(ev=None):
        global running
        running=False
   stopbutton.on_clicked(astop)

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.
Absolutely.
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 callbacks...

Thank you, Fernando.

Jerzy Karczmarczuk

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to