sizer fun (not!)

Hi,

I am having (more) trouble with sizers. I have previously made a small gui that worked as I wanted, however, trying to replicate the structure I used on that is resulting in different behaviour. Here is a peice of the old working code. The main problem is that topPanel.SetSizer(masterBoxSizer) does not work for me in my new code. What I would like to know is, is this code wrong, what is the proper way to set these sizers and lay them up codewise. Are there any suggestions for more robust coding here. wxGlade puts out a whole string of commands that I do not use because when I incorporate them into my code they don't work. I wish I could get a handle on sizers cause it causes so many problems with making new GUI's!

Any help appreciated, if you would like a wiser snippet of the code please let me know.

         #Create a master boxSizer
         masterBoxSizer = wx.BoxSizer(wx.VERTICAL)
         btnBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
         fgs = wx.FlexGridSizer(4, 2, 10, 10)

         #layout masterBoxSizer
         masterBoxSizer.Add(titleTxt, 0, wx.ALL | wx.ALIGN_CENTER)
         masterBoxSizer.Add(fgs, 0, wx.ALL | wx.ALIGN_CENTER)
         masterBoxSizer.Add(btnBoxSizer, 0, wx.ALL | wx.ALIGN_CENTER)

         #layout btnBoxSizer
         btnBoxSizer.Add(closeBtn, 1, wx.ALL, 1)
         btnBoxSizer.Add(applyBtn, 1, wx.ALL, 1)

         #layout fgs
         fgs.Add(sceneTxt, 0)
         fgs.Add(sceneCB, 0)
         fgs.Add(shotTxt, 0, wx.EXPAND)
         fgs.Add(shotCB, 1, wx.EXPAND)
         fgs.Add(versionTxt, 0, wx.EXPAND)
         fgs.Add(versionCB, 1, wx.EXPAND)

         fgs.AddGrowableCol(0)
         fgs.AddGrowableRow(0)
         fgs.AddGrowableCol(1)
         fgs.AddGrowableRow(1)

         topPanel.SetSizer(masterBoxSizer)

regards,
aaron.

aaron barclay wrote:

Hi,

I am having (more) trouble with sizers. I have previously made a small gui that worked as I wanted, however, trying to replicate the structure I used on that is resulting in different behaviour. Here is a peice of the old working code. The main problem is that topPanel.SetSizer(masterBoxSizer) does not work for me in my new code.

It what way does it not work?

What I would like to know is, is this code wrong, what is the proper way to set these sizers and lay them up codewise. Are there any suggestions for more robust coding here. wxGlade puts out a whole string of commands that I do not use because when I incorporate them into my code they don't work. I wish I could get a handle on sizers cause it causes so many problems with making new GUI's!

Any help appreciated, if you would like a wiser snippet of the code please let me know.

Nothing is jumping out at me as being wrong so please make a small sample that shows the problem you are having.

BTW, as has been mentioned here before, even if you don't use the xrc code it generates, playing with XRCed is an easy way to get a good feeling for how sizers work.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!