sizer issues - no change on resize

Hi all,
I have a class inherited from wx.Frame.
In this I have placed a wx.Panel and then some sizers:

        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.mainDisplaySizer = wx.BoxSizer(wx.HORIZONTAL)
        self.grid = wx.GridSizer(10,2,10,5)
        self.buttonSizer = wx.BoxSizer(wx.VERTICAL)

The mainSizer has a static text at the top and then the
mainDisplaySizer.
Inside the mainDisplaySizer I have added a staticText as a 'left
margin' then I've added self.grid, then another staticText as an
'inside margin' and then the buttonSizer.

It all looks fine in terms of layout but the issues are:
1. I would like the frame to open up at the correct size to fit all of
its contents nicely but without setting its size explicitly in the
__init__ method.
2. Also, even if I do explicitly set the size, any resizing that I do
doesn't affect any of the widgets.

I was under the impression from the reading I've been doing on various
sites that the point of me using sizers is that the widgets' size
would adapt to window resizing. I figure I am not using them quite
correctly but haven't really been able to figure out what I'm doing.

Any ideas?

thanks in advance
Aaron

I know this is probably going to feel annoying, but I would check out
http://wiki.wxpython.org/AnotherTutorial#Layout__Management

also: UsingSizers - wxPyWiki

(see point #3 about setting the frame size from a default or config)

It sounds like you've already been looking at similar sites so if you
could post more of your code that would enable us to help more
effectively:

where you add widgets to the sizers
where you SetSizerAndFit (and other layout methods)

- michael

···

On Oct 10, 5:55 pm, apeach <alpeac...@gmail.com> wrote:

Hi all,
I have a class inherited from wx.Frame.
In this I have placed a wx.Panel and then some sizers:

    self\.mainSizer = wx\.BoxSizer\(wx\.VERTICAL\)
    self\.mainDisplaySizer = wx\.BoxSizer\(wx\.HORIZONTAL\)
    self\.grid = wx\.GridSizer\(10,2,10,5\)
    self\.buttonSizer = wx\.BoxSizer\(wx\.VERTICAL\)

The mainSizer has a static text at the top and then the
mainDisplaySizer.
Inside the mainDisplaySizer I have added a staticText as a 'left
margin' then I've added self.grid, then another staticText as an
'inside margin' and then the buttonSizer.

It all looks fine in terms of layout but the issues are:
1. I would like the frame to open up at the correct size to fit all of
its contents nicely but without setting its size explicitly in the
__init__ method.
2. Also, even if I do explicitly set the size, any resizing that I do
doesn't affect any of the widgets.

I was under the impression from the reading I've been doing on various
sites that the point of me using sizers is that the widgets' size
would adapt to window resizing. I figure I am not using them quite
correctly but haven't really been able to figure out what I'm doing.

Any ideas?

thanks in advance
Aaron

I'm sure it's something simple. Please post a small runnable sample,
as defined here:

http://wiki.wxpython.org/MakingSampleApps

che

···

On Sat, Oct 10, 2009 at 6:55 PM, apeach <alpeachey@gmail.com> wrote:

Hi all,
I have a class inherited from wx.Frame.
In this I have placed a wx.Panel and then some sizers:

   self\.mainSizer = wx\.BoxSizer\(wx\.VERTICAL\)
   self\.mainDisplaySizer = wx\.BoxSizer\(wx\.HORIZONTAL\)
   self\.grid = wx\.GridSizer\(10,2,10,5\)
   self\.buttonSizer = wx\.BoxSizer\(wx\.VERTICAL\)

The mainSizer has a static text at the top and then the
mainDisplaySizer.
Inside the mainDisplaySizer I have added a staticText as a 'left
margin' then I've added self.grid, then another staticText as an
'inside margin' and then the buttonSizer.

It all looks fine in terms of layout but the issues are:
1. I would like the frame to open up at the correct size to fit all of
its contents nicely but without setting its size explicitly in the
__init__ method.
2. Also, even if I do explicitly set the size, any resizing that I do
doesn't affect any of the widgets.

I was under the impression from the reading I've been doing on various
sites that the point of me using sizers is that the widgets' size
would adapt to window resizing. I figure I am not using them quite
correctly but haven't really been able to figure out what I'm doing.

Any ideas?

Thanks for the responses guys. I had been following the Layout
Management tutorial but not the 'UsingSizers' one. Worknig through
that now to see if I can enlighten myself.
If I still can't figure it out, I'll post some more relevant code.

thanks
Aaron

···

On Oct 12, 3:53 am, michael h <michaelke...@gmail.com> wrote:

I know this is probably going to feel annoying, but I would check outhttp://wiki.wxpython.org/AnotherTutorial#Layout__Management

also:UsingSizers - wxPyWiki

(see point #3 about setting the frame size from a default or config)

It sounds like you've already been looking at similar sites so if you
could post more of your code that would enable us to help more
effectively:

where you add widgets to the sizers
where you SetSizerAndFit (and other layout methods)

- michael

On Oct 10, 5:55 pm, apeach <alpeac...@gmail.com> wrote:

> Hi all,
> I have a class inherited from wx.Frame.
> In this I have placed a wx.Panel and then some sizers:

> self.mainSizer = wx.BoxSizer(wx.VERTICAL)
> self.mainDisplaySizer = wx.BoxSizer(wx.HORIZONTAL)
> self.grid = wx.GridSizer(10,2,10,5)
> self.buttonSizer = wx.BoxSizer(wx.VERTICAL)

> The mainSizer has a static text at the top and then the
> mainDisplaySizer.
> Inside the mainDisplaySizer I have added a staticText as a 'left
> margin' then I've added self.grid, then another staticText as an
> 'inside margin' and then the buttonSizer.

> It all looks fine in terms of layout but the issues are:
> 1. I would like the frame to open up at the correct size to fit all of
> its contents nicely but without setting its size explicitly in the
> __init__ method.
> 2. Also, even if I do explicitly set the size, any resizing that I do
> doesn't affect any of the widgets.

> I was under the impression from the reading I've been doing on various
> sites that the point of me using sizers is that the widgets' size
> would adapt to window resizing. I figure I am not using them quite
> correctly but haven't really been able to figure out what I'm doing.

> Any ideas?

> thanks in advance
> Aaron

Hi all,
I have a class inherited from wx.Frame.
In this I have placed a wx.Panel and then some sizers:

         self.mainSizer = wx.BoxSizer(wx.VERTICAL)
         self.mainDisplaySizer = wx.BoxSizer(wx.HORIZONTAL)
         self.grid = wx.GridSizer(10,2,10,5)
         self.buttonSizer = wx.BoxSizer(wx.VERTICAL)

The mainSizer has a static text at the top and then the
mainDisplaySizer.
Inside the mainDisplaySizer I have added a staticText as a 'left
margin' then I've added self.grid, then another staticText as an
'inside margin' and then the buttonSizer.

It all looks fine in terms of layout but the issues are:
1. I would like the frame to open up at the correct size to fit all of
its contents nicely but without setting its size explicitly in the
__init__ method.

Also put the panel in a sizer that's assigned to the frame, and then do frame.Fit()

2. Also, even if I do explicitly set the size, any resizing that I do
doesn't affect any of the widgets.

You are probably not setting the sizers or items within them to be expandable.

···

On 10/10/09 3:55 PM, apeach wrote:

--
Robin Dunn
Software Craftsman

Thanks alot all.
I've got the desired effect now.
self.Fit() in the frame's class did what I wanted and setting
wx.EXPAND in the Add methods for the sizers was what I was missing in
regards to having them "resize" when I resize the frame.

New issue...
I have enhanced the app a bit since my original post and the
wx.GridSizer is now a wx.FlexGridSizer (I needed my labels to be in a
narrower column than my text boxes!).
The entire flex grid sizer is inside a StaticBoxSizer but I've noticed
since doing that, I can no longer tab between the wx.TextCtrls inside
the StaticBoxSizer (It worked when it was just a flex grid sizer but
not since I placed it into a StaticBoxSizer)
My frame class sets the focus to the first TextCtrl upon __init__ so
the cursor sits there initially when the app begins but I can't tab it
from there to anywhere else (even out of the StaticBoxSizer).
The strange thing about this - it only happens on my Linux machine, I
can still use tab without issues on Windows XP.

Is this a known issue with Linux and StaticBoxSizers? Any other ideas?

thanks again
Aaron

···

On Oct 13, 6:17 am, Robin Dunn <ro...@alldunn.com> wrote:

On 10/10/09 3:55 PM, apeach wrote:

> Hi all,
> I have a class inherited from wx.Frame.
> In this I have placed a wx.Panel and then some sizers:

> self.mainSizer = wx.BoxSizer(wx.VERTICAL)
> self.mainDisplaySizer = wx.BoxSizer(wx.HORIZONTAL)
> self.grid = wx.GridSizer(10,2,10,5)
> self.buttonSizer = wx.BoxSizer(wx.VERTICAL)

> The mainSizer has a static text at the top and then the
> mainDisplaySizer.
> Inside the mainDisplaySizer I have added a staticText as a 'left
> margin' then I've added self.grid, then another staticText as an
> 'inside margin' and then the buttonSizer.

> It all looks fine in terms of layout but the issues are:
> 1. I would like the frame to open up at the correct size to fit all of
> its contents nicely but without setting its size explicitly in the
> __init__ method.

Also put the panel in a sizer that's assigned to the frame, and then do
frame.Fit()

> 2. Also, even if I do explicitly set the size, any resizing that I do
> doesn't affect any of the widgets.

You are probably not setting the sizers or items within them to be
expandable.

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

Is the static box created before the other widgets and are the other widgets siblings (not children) of the static box? Is the parent a panel with the wx.TAB_TRAVERSAL style?

···

On 10/13/09 2:18 AM, apeach wrote:

I have enhanced the app a bit since my original post and the
wx.GridSizer is now a wx.FlexGridSizer (I needed my labels to be in a
narrower column than my text boxes!).
The entire flex grid sizer is inside a StaticBoxSizer but I've noticed
since doing that, I can no longer tab between the wx.TextCtrls inside
the StaticBoxSizer (It worked when it was just a flex grid sizer but
not since I placed it into a StaticBoxSizer)
My frame class sets the focus to the first TextCtrl upon __init__ so
the cursor sits there initially when the app begins but I can't tab it
from there to anywhere else (even out of the StaticBoxSizer).
The strange thing about this - it only happens on my Linux machine, I
can still use tab without issues on Windows XP.

--
Robin Dunn
Software Craftsman

Sorry for the delayed response all. I've been away for a few days.
Robin - thank you so much once again. Explicitly stating
wx.TAB_TRAVERSAL in the parent panel's call fixed it.
Thanks again...

Aaron

···

On Oct 14, 11:30 am, Robin Dunn <ro...@alldunn.com> wrote:

On 10/13/09 2:18 AM, apeach wrote:

> I have enhanced the app a bit since my original post and the
> wx.GridSizer is now a wx.FlexGridSizer (I needed my labels to be in a
> narrower column than my text boxes!).
> The entire flex grid sizer is inside a StaticBoxSizer but I've noticed
> since doing that, I can no longer tab between the wx.TextCtrls inside
> the StaticBoxSizer (It worked when it was just a flex grid sizer but
> not since I placed it into a StaticBoxSizer)
> My frame class sets the focus to the first TextCtrl upon __init__ so
> the cursor sits there initially when the app begins but I can't tab it
> from there to anywhere else (even out of the StaticBoxSizer).
> The strange thing about this - it only happens on my Linux machine, I
> can still use tab without issues on Windows XP.

Is the static box created before the other widgets and are the other
widgets siblings (not children) of the static box? Is the parent a
panel with the wx.TAB_TRAVERSAL style?

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