Layout 'snaps' into place on resize

I’ve created a simple GUI but all the controls are bundled together until the slightest resize, upon which it looks perfect. I’ve had this issue before and it’s been solved by calling self.Layout() but that doesn’t work in this case. Simple runnable attached, I’m probably missing something obvious. If I adjust the proportion argument (from 1 to 0) when adding the panel to the main sizer the controls don’t cluster anymore but my panel doesn’t take up the whole frame as I want to.

gui.py (2.57 KB)

Hi John,

I've created a simple GUI but all the controls are bundled together until the slightest resize, upon which it looks perfect. I've had this issue before and it's been solved by calling self.Layout() but that doesn't work in this case. Simple runnable attached, I'm probably missing something obvious. If I adjust the proportion argument (from 1 to 0) when adding the panel to the main sizer the controls don't cluster anymore but my panel doesn't take up the whole frame as I want to. --

Works for me on Windows 7, wxPython 2.9.5 and Python 2.7.

IIRC, PySimpleApp and InitAllImageHandlers are deprecated in 2.9

I had replaced your PySimpleApp etc with the following as I always use the wit to debug sizer issues - try it by running your script and pressing ctrl-alt-i.

if __name__ == "__main__":
     import wx.lib.mixins.inspection as wit
     app = wit.InspectableApp(0)
     frame_1 = MainFrame(None, -1, "")
     app.SetTopWindow(frame_1)
     frame_1.Show()
     app.MainLoop()

I would also suggest to name your controls, sizers etc with meaning full names - I believe wxGlade lets you name things instead of just taking the defaults.

Werner

···

On 15/01/2013 14:07, johnharris85 wrote:

Really strange. I’m on wx2.8 (py2.7, win7). I’ve just replaced my PySimpleApp etc with your code above and run, no difference. When I resize it works fine. Before and after resizing images attached. Is this something that might be fixed in wx2.9? Is 2.9 stable?

Thanks a lot for your help.

···

On Tuesday, 15 January 2013 13:39:43 UTC, werner wrote:

Hi John,

On 15/01/2013 14:07, johnharris85 wrote:

I’ve created a simple GUI but all the controls are bundled together
until the slightest resize, upon which it looks perfect. I’ve had this
issue before and it’s been solved by calling self.Layout() but that
doesn’t work in this case. Simple runnable attached, I’m probably
missing something obvious. If I adjust the proportion argument (from 1
to 0) when adding the panel to the main sizer the controls don’t
cluster anymore but my panel doesn’t take up the whole frame as I want
to. –

Works for me on Windows 7, wxPython 2.9.5 and Python 2.7.

IIRC, PySimpleApp and InitAllImageHandlers are deprecated in 2.9

I had replaced your PySimpleApp etc with the following as I always use
the wit to debug sizer issues - try it by running your script and
pressing ctrl-alt-i.

if name == “main”:

 import wx.lib.mixins.inspection as wit

 app = wit.InspectableApp(0)

 frame_1 = MainFrame(None, -1, "")

 app.SetTopWindow(frame_1)

 frame_1.Show()

 app.MainLoop()

I would also suggest to name your controls, sizers etc with meaning full
names - I believe wxGlade lets you name things instead of just taking
the defaults.

Werner

Hi,
I can confirm, that the original code works fine for me on wxpython 2.9 (win 7);
as for wx 2.8, you may try to use an intermediate panel as the only
child of the toplevel frame and as the parent of all the items.
cf. e.g. the following comment as an explanation:
https://groups.google.com/forum/#!msg/wxpython-users/aW3fo8ddLnc/oxb2eaXa-bUJ

The attached rather hackish modification works on wx 2.8 and 2.9
without difference for me,
I just changed the base class
"class MainFrame(wx.Panel):"
edited the necessary parts depending on the differences between
wx.Frame and wx.Panel

and added:
    frame_1 = wx.Frame(None, -1, "GUI title", pos=(-1,-1), size=(-1,-1))
    pnl = MainFrame(frame_1)

Its meant rather as a test, you would obviously want to code the panel
into the app more appropriately.
(I am not sure about the possibilities in wxGlade to make it work like
this by default.)

hth,
  vbr

gui_modif.py (2.89 KB)

···

2013/1/15 johnharris85 <john@johnharris.tv>:

I've created a simple GUI but all the controls are bundled together until
the slightest resize, upon which it looks perfect. I've had this issue
before and it's been solved by calling self.Layout() but that doesn't work
in this case. Simple runnable attached, I'm probably missing something
obvious. If I adjust the proportion argument (from 1 to 0) when adding the
panel to the main sizer the controls don't cluster anymore but my panel
doesn't take up the whole frame as I want to.

Thanks all. I’ve updated to wx2.9 and all is fixed :smiley:

···

On Tuesday, 15 January 2013 15:12:26 UTC, vbr wrote:

2013/1/15 johnharris85 jo...@johnharris.tv:

I’ve created a simple GUI but all the controls are bundled together until

the slightest resize, upon which it looks perfect. I’ve had this issue

before and it’s been solved by calling self.Layout() but that doesn’t work

in this case. Simple runnable attached, I’m probably missing something

obvious. If I adjust the proportion argument (from 1 to 0) when adding the

panel to the main sizer the controls don’t cluster anymore but my panel

doesn’t take up the whole frame as I want to.

Hi,

I can confirm, that the original code works fine for me on wxpython 2.9 (win 7);

as for wx 2.8, you may try to use an intermediate panel as the only

child of the toplevel frame and as the parent of all the items.

cf. e.g. the following comment as an explanation:

https://groups.google.com/forum/#!msg/wxpython-users/aW3fo8ddLnc/oxb2eaXa-bUJ

The attached rather hackish modification works on wx 2.8 and 2.9

without difference for me,

I just changed the base class

“class MainFrame(wx.Panel):”

edited the necessary parts depending on the differences between

wx.Frame and wx.Panel

and added:

frame_1 = wx.Frame(None, -1, "GUI title", pos=(-1,-1), size=(-1,-1))

pnl = MainFrame(frame_1)

Its meant rather as a test, you would obviously want to code the panel

into the app more appropriately.

(I am not sure about the possibilities in wxGlade to make it work like

this by default.)

hth,

vbr

Really strange. I'm on wx2.8 (py2.7, win7).

Problem is there.

I've just replaced my PySimpleApp etc with your code above and run, no difference.

Yes, replacing PySimpleApp will not make it work differently, but press ctrl-alt-i and look at the hierarchy of your controls and sizers in the WIT.

You are adding the StaticBoxSizer to the "parent sizer" it should be the box in 2.8 and in 2.9 it should be done differently (see the 2.9.5 wxPython demo).

When I resize it works fine. Before and after resizing images attached. Is this something that might be fixed in wx2.9?

Looking some more even in 2.9 it does not work nicely, i.e. making it larger not everything grows.

There are lots of changes in 2.9, and sizers are in some way changed, and the way the staticbox stuff works is changed too (http://wxpython.org/Phoenix/docs/html/StaticBoxSizer.html)

Is 2.9 stable?

If it is new development you are doing use 2.9, despite the label "non stable" it is at least as stable as 2.8 and you will have less work moving up to Phoenix when it comes out. The label 'non stable' applies to the API changes and not stability in general.

Werner

···

On 15/01/2013 15:07, johnharris85 wrote: