Panel with two Matplotlib FigureCanvas resizes just after resizing frame

Hey,
I’m developing a plotter for wavefiles using wxpython and matplotlib.
For this I have a panel with two Matplotlib FigureCanvases in it, and everytime I load a new file, the canvases just resize after I change the size of the whole frame.
In my code I plot no file because this works correct and I want to keep it as simple as possible, but it’s the same structure like in my original code.
I also tried to set the size of the figures by myself when I create the figure, but this doesn’t work ( the figure just has the right W/H ratio) - you can see this in the Plotter.createPlots () method (commented out).
Thank you in advance :slight_smile:
Richard

plot.py (2.23 KB)

Hey,
I'm developing a plotter for wavefiles using wxpython and matplotlib.
For this I have a panel with two Matplotlib FigureCanvases in it, and
everytime I load a new file, the canvases just resize after I change the
size of the whole frame.
In my code I plot no file because this works correct and I want to keep it
as simple as possible, but it's the same structure like in my original
code.
I also tried to set the size of the figures by myself when I create the
figure, but this doesn't work ( the figure just has the right W/H ratio) -
you can see this in the Plotter.createPlots () method (commented out).
Thank you in advance :slight_smile:

Richard

What is your question?

It seems like you don't want the plot canvases to be resized? Is that it?
If so, then you can change this line:

self.sizer.Add(canvas, 1, wx.GROW)

to just

self.sizer.Add(canvas)

I prefer them resizing, though.

Che

···

On Tue, Apr 29, 2014 at 11:36 AM, Richard Papen <ehcam17@googlemail.com>wrote:

Sorry if I was a bit inconcrete.
My problem is that if I create a new plot, it isn’t sized right. (looks like in screen1)
I have to change the size of the frame to get it sized that it looks like in screen2.
But I want it to be sized right like in screen 2 immediately after I created a new.

screen1.PNG

screen2.PNG

Weird. I have tried for a while and can't figure out what's wrong. I
thought a Layout() call would fix it, but it's not doing it.

A kludge way to make it work is to make a reference to self.parent in the
__init__ of PlotPanel, then add this:

self.parent.SendSizeEvent()

to the end of the createNewPlot function. But a more satisfying and
correct answer will likely get posted at some point soon.

···

On Tue, Apr 29, 2014 at 4:37 PM, Richard Papen <ehcam17@googlemail.com>wrote:

Sorry if I was a bit inconcrete.
My problem is that if I create a new plot, it isn't sized right. (looks
like in screen1)
I have to change the size of the frame to get it sized that it looks like
in screen2.
But I want it to be sized right like in screen 2 immediately after I
created a new.

If I add self.GetParent().SendSizeEvent() in the end of createNewPlot(), it works.
Thank You :slight_smile: