wx.lib.plot size appears to be broken in some way

Hi

I have a nice class derived from wx.lib.plot for calculating and
display a linear regression. In my test app the class worked
perfectly. When I inserted the class into my actual application it
fails to resize correctly. It ignores any attempt to set the control
size, it is always about 20 x 20 pixels. If I set the size parameter
when I instantiate, (I've carefully checked that I'm correctly calling
the parent class __init__) it reports that it is the requested size,
likewise if I call the setsize method. But it is always 20 x 20.
I've tried calling layout in various places with no effect. I went
back to my test app. In this I am using a boxsizer to expand the
controls which works fine. If I try to call the setsize method it
also fails. So I went back to my actual app and put the plot into a
panel with a sizer and it has no effect. Interestingly my plotting
appears to be occurring correctly in the tiny window. just not very
usefully.

From

https://groups.google.com/group/wxpython-users/browse_thread/thread/cabe8a68e72d82ec/884d7691c1503966?hl=en&lnk=gst&q=plot+#884d7691c1503966

I see that I'm not the only one who has had these difficulties. I've
tried tracing into the all python source but it is extremely
convoluted and not well commented so I can't follow what is meat to be
going on.

Has anyone had any success using wx.lib.plot? I don't won't to give
it up on it as it has advantages over matplot lib and chaco in that it
is very light weight a quick.

Thanks

If you make a small sample and post it here, someone may well help you fix it:

http://wiki.wxpython.org/MakingSampleApps

I"d do a small-as-possible app with a frame with a sizer with a
wx.lib.plot window in it, and see what you get.

-Chris

···

On Tue, Jan 31, 2012 at 8:02 AM, PeterW <peter@4doptics.com> wrote:

Hi

I have a nice class derived from wx.lib.plot for calculating and
display a linear regression. In my test app the class worked
perfectly. When I inserted the class into my actual application it
fails to resize correctly. It ignores any attempt to set the control
size, it is always about 20 x 20 pixels. If I set the size parameter
when I instantiate, (I've carefully checked that I'm correctly calling
the parent class __init__) it reports that it is the requested size,
likewise if I call the setsize method. But it is always 20 x 20.
I've tried calling layout in various places with no effect. I went
back to my test app. In this I am using a boxsizer to expand the
controls which works fine. If I try to call the setsize method it
also fails. So I went back to my actual app and put the plot into a
panel with a sizer and it has no effect. Interestingly my plotting
appears to be occurring correctly in the tiny window. just not very
usefully.

From

https://groups.google.com/group/wxpython-users/browse_thread/thread/cabe8a68e72d82ec/884d7691c1503966?hl=en&lnk=gst&q=plot+#884d7691c1503966

I see that I'm not the only one who has had these difficulties. I've
tried tracing into the all python source but it is extremely
convoluted and not well commented so I can't follow what is meat to be
going on.

Has anyone had any success using wx.lib.plot? I don't won't to give
it up on it as it has advantages over matplot lib and chaco in that it
is very light weight a quick.

Thanks

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

The plot window doesn't have a best size calculation for the sizers to use, so unless the sizer is set to fully expand it into a larger space you will need to give it an explicit min size. The sizer and parent sizers will use that value when calculating the layout and deciding how much room to reserve for the plot window. Try something like myPlot.SetMinSize((300,200)) to start out with.

···

On 1/31/12 8:02 AM, PeterW wrote:

Hi

I have a nice class derived from wx.lib.plot for calculating and
display a linear regression. In my test app the class worked
perfectly. When I inserted the class into my actual application it
fails to resize correctly. It ignores any attempt to set the control
size, it is always about 20 x 20 pixels. If I set the size parameter
when I instantiate, (I've carefully checked that I'm correctly calling
the parent class __init__) it reports that it is the requested size,
likewise if I call the setsize method. But it is always 20 x 20.
I've tried calling layout in various places with no effect. I went
back to my test app. In this I am using a boxsizer to expand the
controls which works fine. If I try to call the setsize method it
also fails. So I went back to my actual app and put the plot into a
panel with a sizer and it has no effect. Interestingly my plotting
appears to be occurring correctly in the tiny window. just not very
usefully.

--
Robin Dunn
Software Craftsman

Thanks Robin

I'm not sure what you mean by "sizer is set to fully expand it", I've
set the wx.EXPAND flag and it does nothing.
However SetMinSize did the trick and the sizer now correctly expands
the plot.
But why doesn't SetSize work?

Cheers

Peter

···

On Jan 31, 5:28 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 1/31/12 8:02 AM, PeterW wrote:

> Hi

> I have a nice class derived from wx.lib.plot for calculating and
> display a linear regression. In my test app the class worked
> perfectly. When I inserted the class into my actual application it
> fails to resize correctly. It ignores any attempt to set the control
> size, it is always about 20 x 20 pixels. If I set the size parameter
> when I instantiate, (I've carefully checked that I'm correctly calling
> the parent class __init__) it reports that it is the requested size,
> likewise if I call the setsize method. But it is always 20 x 20.
> I've tried calling layout in various places with no effect. I went
> back to my test app. In this I am using a boxsizer to expand the
> controls which works fine. If I try to call the setsize method it
> also fails. So I went back to my actual app and put the plot into a
> panel with a sizer and it has no effect. Interestingly my plotting
> appears to be occurring correctly in the tiny window. just not very
> usefully.

The plot window doesn't have a best size calculation for the sizers to
use, so unless the sizer is set to fully expand it into a larger space
you will need to give it an explicit min size. The sizer and parent
sizers will use that value when calculating the layout and deciding how
much room to reserve for the plot window. Try something like
myPlot.SetMinSize((300,200)) to start out with.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

I'm not sure what you mean by "sizer is set to fully expand it", I've
set the wx.EXPAND flag and it does nothing.

I"m not sure what sizer you are using, or how -- Minimal application, anyone?

but for BoxSizers, the wx.EXPAND flag determines behavior orthogonal
to the direction of the sizer, and the "option" parameter the behavior
along the direction of the sizer. To have it fully fill the space,
something like this:

Sizer.Add(MyPlotWindow, 1, wx.EXPAND)

But if you call a Fit, then the sizer tries to make everything as
small as possible, so if there is no MInSize, you could get a very
small PLotWindow.

-Chris

···

On Wed, Feb 1, 2012 at 8:17 AM, PeterW <peter@4doptics.com> wrote:

However SetMinSize did the trick and the sizer now correctly expands
the plot.
But why doesn't SetSize work?

Cheers

Peter

On Jan 31, 5:28 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 1/31/12 8:02 AM, PeterW wrote:

> Hi

> I have a nice class derived from wx.lib.plot for calculating and
> display a linear regression. In my test app the class worked
> perfectly. When I inserted the class into my actual application it
> fails to resize correctly. It ignores any attempt to set the control
> size, it is always about 20 x 20 pixels. If I set the size parameter
> when I instantiate, (I've carefully checked that I'm correctly calling
> the parent class __init__) it reports that it is the requested size,
> likewise if I call the setsize method. But it is always 20 x 20.
> I've tried calling layout in various places with no effect. I went
> back to my test app. In this I am using a boxsizer to expand the
> controls which works fine. If I try to call the setsize method it
> also fails. So I went back to my actual app and put the plot into a
> panel with a sizer and it has no effect. Interestingly my plotting
> appears to be occurring correctly in the tiny window. just not very
> usefully.

The plot window doesn't have a best size calculation for the sizers to
use, so unless the sizer is set to fully expand it into a larger space
you will need to give it an explicit min size. The sizer and parent
sizers will use that value when calculating the layout and deciding how
much room to reserve for the plot window. Try something like
myPlot.SetMinSize((300,200)) to start out with.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Thanks Robin

I'm not sure what you mean by "sizer is set to fully expand it", I've
set the wx.EXPAND flag and it does nothing.

What Chris said. :wink:

However SetMinSize did the trick and the sizer now correctly expands
the plot.
But why doesn't SetSize work?

SetSize just does that, changes the size of the window. The sizer is also responsible for setting the size of the window, but in most cases the sizer does not care what the current size of the window is, just the best size the window calculates for itself and/or the min size set by the program.

···

On 2/1/12 8:17 AM, PeterW wrote:

--
Robin Dunn
Software Craftsman