Animation Broken WXAgg OS X

I had problems getting animation to work in WXAgg but I assumed it was my fault.
I recently installed Matplolib 0.87.1cvs version on OS X 10.4.5

I ran the examples/anim.py and animation works in TkAgg and it worked fine.
I ran the same script with WxAgg and animation does not work. The graph window is blank during the animation.
I also tried CocoaAgg with similar result except that it also appears to hang. It could be a really really slow frame
rate but I didn't wait around to find out.
Has anybody ever tested animation on WXAgg on OS X?

pythonw anim.py -dTkAgg
...
FPS: 5.21548384568

···

**********************************************************************
Samuel M. Smith Ph.D.
2966 Fort Hill Road
Eagle Mountain, Utah 84043
801-768-2768 voice
801-768-2769 fax
**********************************************************************
"The greatest source of failure and unhappiness in the world is
giving up what we want most for what we want at the moment"
**********************************************************************

I ran the examples/anim.py and animation works in TkAgg and it worked fine.
I ran the same script with WxAgg and animation does not work. The graph window is blank during the animation.

My take on this is that wxPython-mac can't repaint the plot window if it's not running its event loop.

I have attached an example of animating WXAgg plots by redrawing them from within an idle event callback. If you're building an application that uses matplotlib for visualization, you can redraw the plot from within the running application without any problems (e.g. when new data arrives). You may also want to check out the animation_blit_wx.py example, which works more or less the same way.

I also tried CocoaAgg with similar result except that it also appears to hang. It could be a really really slow frame rate but I didn't wait around to find out.

Since wxPython-mac is built on top of Cocoa, I'd imagine Cocoa has similar repainting problems.

Ken

anim_wx.py (1.88 KB)

···

On Mar 7, 2006, at 6:18 PM, Samuel M. Smith wrote:

Ken McIvor wrote:

My take on this is that wxPython-mac can't repaint the plot window if it's not running its event loop.

This might have something to do with the fact that OS-X double buffers it's windows, so you need to force and update event somehow. A call to wx.Window.Refresh() and/or wx.Window.Update() might do it. However, I haven't had any problem with just using a wxClientDC in my apps, but I guess I've always been running an event loop. Maybe OS-X waits for a Idle event to update the screen.

What kind of app would you have running without an event loop anyway? Id didn't think you could do much at all without one in wx.

Since wxPython-mac is built on top of Cocoa, I'd imagine Cocoa has similar repainting problems.

wxPython-mac is built in Carbon, not Cocoa, but they do both use Quartz

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

This might have something to do with the fact that OS-X double buffers it's windows, so you need to force and update event somehow. A call to wx.Window.Refresh() and/or wx.Window.Update() might do it.

For `examples/anim.py', calling line.axes.figure.canvas.Update() after each call to pylab.draw() appears to do the trick.

Maybe OS-X waits for a Idle event to update the screen.

The wxWidgets documentation for wxWindow::Refresh() and wxWindow::Update() indicates that the event loop is the default method for driving screen repaints.

What kind of app would you have running without an event loop anyway?

Apparently, pylab scripts that try to animate plots by redrawing them run without an event loop. I could be mistaken, but I don't think the loop is started until you call pylab.show(). See `examples/anim.py' for an example of what I'm talking about.

Id didn't think you could do much at all without one in wx.

I didn't think so either but I hadn't considered pylab. Since a matplotlib example was the initial source of the problem, I think we should probably change things so that Update() gets called when necessary. My proposal is to tack the following (untested) lines to the end of backend_wx.FigureCanvasWx.gui_repaint():

  # force a repaint if we think we're a pylab figure
  if isinstance(self.GetParent(), FigureFrameWx):
    self.Update()

Ken

···

On Mar 10, 2006, at 2:56 PM, Christopher Barker wrote: