[wxPython] Sizer problems after upgrading to 2.3

Hi guys,

I've just taken the plunge and upgraded my copy of wxPython from 2.2.5 to 2.3. So far, it looks great -- it took me all of five minutes to find and fix the minor problems I had with my code. Unfortunately, though, there's one thing which has me completely stumped: one of the dialog boxes I was using previously no longer lays itself out correctly.

This seems to be a pretty straightforward dialog box, with a wxStaticText field for a prompt and a single wxTextCtrl subclass for entering a value. I'm using three wxBoxSizers: one to lay out the label and prompt, another to lay out the buttons, and a third to place the other two sizers one above the other in the window.

As I say, this worked fine under 2.2.5, but for some reason fails with 2.3. The window is the correct width but is *far* higher than it needs to be, with the text fields at the top and the buttons shoved all the way to the botton. Have I missed something obvious here, or has something subtle changed in wxPython from 2.2.5 to 2.3 which I'm not aware of?

The code below shows the problem. Any suggestions would be most welcome...

Thanks in advance,

  - Erik.

PS: Robin: I really appreciate all the work you've done in 2.3. The new "hybrid" version with wxWindow assertions is brilliant!

------- Python code follows

···

----------------------------------------------------

from wxPython.wx import *

class TestFrame(wxFrame):
     def __init__(self):
         wxFrame.__init__(self, None, -1, "Test")

         label = wxStaticText(self, -1, "label")
         field = wxTextCtrl(self, -1)

         btnOK = wxButton(self, wxID_OK, "OK")
         btnCancel = wxButton(self, wxID_CANCEL, "Cancel")

         btnOK.SetDefault()

         fieldSizer = wxBoxSizer(wxHORIZONTAL)
         btnSizer = wxBoxSizer(wxHORIZONTAL)
         topSizer = wxBoxSizer(wxVERTICAL)

         fieldSizer.Add(label, 0, wxALL, 5)
         fieldSizer.Add(field, 0, wxALL, 5)

         btnSizer.Add(btnOK, 0, wxALL, 5)
         btnSizer.Add(btnCancel, 0, wxALL, 5)

         topSizer.Add(fieldSizer, wxALL, 10)
         topSizer.Add(btnSizer)

         self.SetAutoLayout(true)
         self.SetSizer(topSizer)
         topSizer.Fit(self)

         self.Centre(wxBOTH)
         field.SetFocus()

class TestApp(wxApp):
     def OnInit(self):
         self.frame = TestFrame()
         self.frame.Raise()
         self.frame.Show(true)

         return true

def main():
     app = TestApp(0)
     app.MainLoop()

if __name__ == "__main__":
     main()

         topSizer.Add(fieldSizer, wxALL, 10)

                                   ^^^
You're missing a zero here.

···

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

Hi Robin,

You're missing a zero here.

Thanks! I thought it must be something obvious, but couldn't for the life of me see it. Strange how it worked fine in 2.2.5 -- it was exactly the same code...

Thanks again,

  - Erik.

>You're missing a zero here.

Thanks! I thought it must be something obvious, but couldn't for the life
of me see it. Strange how it worked fine in 2.2.5 -- it was exactly the
same code...

It was probably due to a couple bug fixes in the sizer code. One of them
may have been giving you this "undocumented feature."

···

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