Hello - I''ve got a wxDialog where, among other
> controls, I have a wxList and a
> FigureCanvasWx. Depending on what single item is
> selected in the wxList, the FigureCanvasWx should show
> the appropriate graph. It's important that the
> matplotlib-generated graph stay in the dialog along
> with the other controls (I don't want to generate a
> separate frame for the graph).
I'm not a wx guru, so this may not be the best way, but it I think it
is a pretty good way. Instead of putting a FigureCanvasWX in your,
use a wxPanel instead. Maintain a list of FigureCanvasAgg and use
them to draw your figures. Transfer these to the wxPanel using string
and bitmap methods. This is effectively what wxagg does. The main
difference is that you will have one canvas and a list of
You can get the width and height of the figure you need to draw with
Suppose agg below is an FigureCanvasAgg instance
s = agg.tostring_rgb()
l,b,w,h = agg.figure.get_window_extent().get_bounds()
image = wxEmptyImage( w,h )
bitmap = image.ConvertToBitmap()
You can then transfer the bitmap to the wxpanel. If you want to do
all the 'draw' calls upfront so you don't have to repeatedly draw if
the user selects one figure, then another, then the original, that
will be fine.
Agg is a pretty fast renderer, which may more than make up for the
performance hit of having to go through the string->bitmap->canvas.
Let me know how it goes.