[Putting this back on list after I mistakenly took it off.]
Hi Ryan,
Thanks for your reply.
In the course of adding the animations, I also
added a "close_event" to the other backends, so that the
timers would stop on figure close and the users wouldn't
get weird messages. Did you happen to add this?I added the close_event to the Mac OS X backend today.
I'm not sure you can move this to figure.draw(renderer),
since that's going to draw *everything*.One solution is to add an .animation attribute to the Figure class, which is None by default (for non-animated drawing).
Roughly, the code should then look as follows:
In the Animation class, the _step method sets Figure.animation and lets the canvas know that it should redraw itself:
def _step(self, *args):
try:
framedata = self.frame_seq.next()
self.figure.animation = self, framedata
self.figure.canvas.draw_idle()
return True
except StopIteration:
return FalseNote that no actual drawing is done here.
In the Figure class, the draw method should then become:
def draw(self, renderer):
if self.animation:
animation, framedata = self.animation
animation._draw_next_frame(framedata, animation._blit)
return
# otherwise, draw as usual.Then all actual drawing is done from inside Figure.draw, which is what the Mac OS X backend needs.
How does this look? If this looks OK, I can try to work out the details and send you the modified code so you can check it out.
I'm not completely wild about it, because it just feels wrong to put
something specific to animation inside figure. The problem we're
trying to solve here is biltting, so is there some way we can improve
how blitting is handled? This would also be a time where we could
(possibly) simplify/improve the blitting API. Do any of the current
uses of blitting work with the MacOSX backend? If those *do* work,
then I'm doing something wrong and need to rework animations. If not,
then we need to find a way to make it so blitting can work in general.
Ryan
···
On Fri, Oct 22, 2010 at 11:45 PM, Michiel de Hoon <mjldehoon@...42...> wrote:
--- On Mon, 10/18/10, Ryan May <rmay31@...149...> wrote:
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma