From: Michiel de H. <mjl...@ya...> - 2013-04-13 02:32:19
|
Dear all, The animation code in matplotlib relies on timers to update the animated figures. Currently a new timer is created by calling new_timer on a canvas, as in >>> f = pylab.figure() >>> timer = f.canvas.new_timer() This seems a bit of a wrinkle. For example, you may want to associate a timer with multiple figures, or with no figure at all; also you may want to continue using a timer after a particular figure is closed. I would therefore propose to make timers independent of canvases. Something like this: >>> from matplotlib import events >>> timer = events.Timer() This has the additional advantage of making the different backends more similar to each other; in the current implementation some backends rely on the canvas when making a timer, while others ignore it. I have made a branch on github that does exactly this; see https://github.com/mdehoon/matplotlib/tree/Timer I have verified that the animation examples still work correctly with all backends. Any comments/suggestions/criticisms? If this seems a good idea, I can make a pull request. Best, -Michiel. |