segfault adding wxStaticText to wxStaticBoxSizer

Hey people,

So, I have the following code...

  def make_left_panel(self):
    left_panel = wxPanel(self, -1, size=(50,50), style=wxNO_BORDER)
    left_panel.SetBackgroundColour("WHITE")

    left_panelbox = wxStaticBox(left_panel,
                                -1,
                                "Current Conditions",
                                size=(50,50))
    left_panelbox.SetFont(self.bfont)

    left_panelbox_sizer = wxStaticBoxSizer(left_panelbox, wxVERTICAL)

======>

    # Add the current conditions grid
    grid_sizer = self.pop_current(left_panel, left_panelbox_sizer)
    left_panelbox_sizer.Add(grid_sizer,
                            1,
                            wxALIGN_CENTER,
                            4)

    left_panel.SetAutoLayout(true)
    left_panel.SetSizer(left_panelbox_sizer)
    left_panel.Layout()

    return left_panel

I tried to add a wxStaticBox above the wxGridSizer that pop_current()
returns. But, when I try to add it, I get a segfault.

My code added at the arrow above was...

text = wxStaticText(left_panelbox, -1, "Description",
                    style=wxALIGN_CENTER)
left_panelbox_sizer.Add(text, 1, wxALIGN_CENTER, 4)

I'm assuming any segfault is a bug. Is this just the wrong way to do
this?

Thanks,
Mike

···

--
Michael P. Soulier <msoulier@digitaltorque.ca>
The major advances in civilization are processes that all but wreck the
societies in which they occur.
-- Albert North Whitehead

Michael P. Soulier wrote:

text = wxStaticText(left_panelbox, -1, "Description",
                    style=wxALIGN_CENTER)
left_panelbox_sizer.Add(text, 1, wxALIGN_CENTER, 4)

I'm assuming any segfault is a bug. Is this just the wrong way to do
this?

wx.StaticBox can't have children, make it a child of left_panel instead. (There should be an exception raised at that point but it's possible that another related error causing the segfault is happening before control returns to the Python code and the exception is actually raised.)

···

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