Animated graphs / wxPython

Kevin Altis altis at semi-retired.com
Sat Feb 9 21:14:44 EST 2002


PythonCard http://pythoncard.sourceforge.net/ includes a BitmapCanvas class
(component) that provides automatic double-buffered drawing and you can
control when updates are made to the on-screen buffer (what the user sees).
The doodle, hopalong, and turtle sample apps included with PythonCard use
the BitmapCanvas class, so there is example code to learn from. You can see
screen shots of the samples in action at
http://pythoncard.sourceforge.net/samples.html The BitmapCanvas component
supports many of the wxDC drawing primitives, but I haven't implemented all
of them yet. If there are particular ones you need such as ellipses
(mentioned below) that would be easy to add.

Since this was done for PythonCard it won't work without modification in a
plain wxPython application, even though PythonCard uses wxPython as its GUI
toolkit. Depending on how far along you are on your wxPython app you might
consider just using PythonCard instead. You could also adapt the
BitmapCanvas class to your own needs or use it as an example of
double-buffered drawing and roll your own.

ka

"Duncan Smith" <buzzard at urubu.freeserve.co.uk> wrote in message
news:a43rur$31f$1 at newsg1.svr.pol.co.uk...
> I need to frequently redraw a graph (ie. nodes and edges) to a wxPython
> panel.  ie. I remove and/or add edges to the graph and then redraw it.  I
am
> currently using wxPython ellipses and lines for drawing the nodes and
edges.
> The problems are the speed of redrawing and the flickering as the window
is
> redrawn.  SetClippingRegion() doesn't help a great deal as the clipping
> region is usually nearly as large as the full graph.  I am currently using
a
> workaround whereby I draw edges in the background colour in order to
remove
> them.  But after a number of redraws the graph starts to get noticeably
> whited out by drawing over existing nodes and edges.
>
> Does anyone know of a better approach?  Ideally I would like to be able to
> simply remove and add edges and send them to the back of the nodes rather
> than redrawing the relevant nodes each time I add an edge.  I have looked
at
> a number of packages, but none seem to be able to do what I want.
> Essentially I want an animated graph that will show a user what the graph
> algorithms are up to.  (Gato won't do the job.)  Thanks in advance.
>
> Duncan
>
>





More information about the Python-list mailing list