From: John H. <jdh...@ac...> - 2004-04-24 14:14:56
|
>>>>> "Engelsma," == Engelsma, Dave <D.E...@La...> writes: Dave> Hello - I''ve got a wxDialog where, among other Dave> controls, I have a wxList and a Dave> FigureCanvasWx. Depending on what single item is Dave> selected in the wxList, the FigureCanvasWx should show Dave> the appropriate graph. It's important that the Dave> matplotlib-generated graph stay in the dialog along Dave> with the other controls (I don't want to generate a Dave> 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 FigureCanvasAggs. You can get the width and height of the figure you need to draw with Suppose agg below is an FigureCanvasAgg instance agg.draw() s = agg.tostring_rgb() l,b,w,h = agg.figure.get_window_extent().get_bounds() image = wxEmptyImage( w,h ) image.SetData(s) 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. JDH |