[SciPy-user] pyqwt or matplotlib

Bryan Cole bryan@cole.uklinux....
Thu Aug 28 16:49:29 CDT 2008

On Thu, 2008-08-28 at 16:07 -0500, Peter Wang wrote:
> On Aug 26, 2008, at 7:25 PM, Zachary Pincus wrote:
> > Another option, depending on how much plumbing you're interested in,
> > is to write a custom tool with OpenGL...
> >
> > I've been using Pyglet for some rather-specialized data display needs
> > (blit live video from a microscope + plot derived measures on top of
> > the video, using the mouse to pan and zoom), and it's pretty nice.
> > Basically, Pyglet is a (pretty simple) pure-python, ctypes-based,
> > multiplatform interface to OpenGL, windowing, and mouse/keyboard IO.
> > It's quite hackable, too -- I rigged up a very simple system to run
> > pyglet windows in a background thread, so I could control the
> > microscope from an interactive python interpreter, while still being
> > able to programmatically interact with pyglet window objects. (Happy
> > to share this code with anyone who desires. It's much cleaner, IMO,
> > than the gyrations that ipython has to go through to support
> > nonblocking QT, Tk, etc. windows. This is becase the pyglet mainloop
> > is in python, and is easy to subclass and otherwise mess with.)
> >
> > The downside is of course that OpenGL isn't a plotting library. The
> > upside is that if you have a well-defined plotting task, and you want
> > full aesthetic control and also high speed, you can get that with not
> > too much work.
> >
> > Just a thought,
> > Zach
> Hey Zach,
> I've been working on an early version of an OpenGL/pyglet-based  
> backend for Chaco.  It currently does most of the plots that are  
> supported in Chaco (although there are issues with the color bar  
> rendering incorrectly).
> I use pyglet to get a window and provide an platform independent API  
> for events, but most of the actual drawing is done via a C++  
> GraphicsContext class that makes calls to libOpenGl.  (I use pyglet to  
> render text and Andrew Straw's pygarrayimage to draw images.)  This  
> GraphicsContext has a transform stack, a clip stack, supports compiled  
> paths, etc.
> I also have my own little "PygletSimpleApp" class analog of  
> WxSimpleApp and whatnot.  It is indeed very nice to have total control  
> over the event loop - so much simpler than fiddling with the Wx event  
> queue!

The GL backend for Chaco is an exciting development. Althought the
examples worked fine with the pyglet backend, when I tried to experiment
with it I couldn't see how to use it within the context of a full
TraitsUI/wx application. Pyglet doesn't seem to integrate with any other
toolkit event loop.

Can the gl_graphics_context be "dropped in" in place of the standard agg
gc? Is there an easy switch to set this up?


> I've tested my code on win32, Ubuntu 7, and OS X.  The beauty of doing  
> it this way is that I can reuse all of the data handling and rendering  
> code from Chaco, and on systems where I have WX or Qt available, I can  
> switch to using those instead of Pyglet by setting a single  
> environment variable.  I'm hoping to get this GL backend polished up  
> enough to release it as a supported part of Chaco, maybe by the next  
> large-ish release (3.1?  3.2?).
> -Peter

More information about the SciPy-user mailing list