Matplotlib in wx.boxsizer instead of panels

243 Views Asked by At

I read here: http://wiki.wxpython.org/Getting%20Started#Windows_or_Frames.3F that there are advantages to arranging content within a frame using Sizers instead of panels; sizers are more flexible. However many of the matplotlib examples with wxpython use panels anyway. Typically they difine a panel for the plot. I have designed a GUI using Sizers, and wish to put my matplotlib canvas into one of the Sizers without the apparent restrictions of a panel. Does anyone know how this is done, or where I can find a very simple example? Many thanks, Andrew.

1

There are 1 best solutions below

0
On

I am not familiar with matplotlib but I happened to come across this previous SO question about embedding matplotlib canvases.

From what I can tell the canvas is actually inside a sizer but that sizer is then wrapped inside a panel. The advantage of this is that you encapsulate all the relevant variables and keep them together. I.e. the canvas and all the relevant variables are kept as a single item that can be called. This is good if you plan to have multiple canvases or if your canvas will be only one part of a more complex GUI.

That said, I see no reason you NEED to put it panel. If your application is very simple (i.e. it will consist of JUST the canvas and nothing else) you could place it in you frame's sizer (see that previous question's answer and change wx.Panel to wx.Frame).