Boa Constructor crashes with StaticBoxSizer

Carla Chua
  • Carla Chua

    Carla Chua - 2011-01-21

    I am having a problem with adding Basic Controls on a StaticBoxSizer.

    I have a StaticBox and StaticBoxSizer and would like to add StaticTexts and the like on the StaticBoxSizer. But as I add the Controls through the Designer, the whole Boa Constructor crashes.
    I don't know what's going on. Is this some sort of a bug? Is there any way to do what I want without the whole Boa Constructor crashing?
    Please help and thank you for the responses in advance.

  • Werner F. Bruhin

    Hi Carlajane,

    The StaticBox/Sizer stuff is a pity "touchy" in Boa, i.e. if certain steps are done exactly right it crashes.

    The good news is that it is possible to do.

    1.  create a Dialog or pane
    2. drop the StaticBox onto it
    3. drop the StaticBoxSizer onto the "Sizer" tab and select the StaticBox created under 2
    4. drop a FlexGridSizer onto the StaticBox in the Designer
    4.a remove the source line "self.staticbox.SetSizer(self.flexgridsizer)
    5. drop a StaticText onto the StaticBox in the Designer
    6. drop a TextCtrl onto the StaticBox in the Designer
    7. drop a box sizer onto the panel (not onto the staticbox) in the designer
    8. add the flexgridsizer onto the StaticBoxSizer in the collection editor which you get from the Sizer tab

    I think this is it.  The source should look something like this.


    import wx
    def create(parent):
        return Dialog1(parent)
    ] = [wx.NewId() for _init_ctrls in range(4)]
    class Dialog1(wx.Dialog):
        def _init_coll_flexGridSizer1_Items(self, parent):
            # generated method, don't edit
            parent.AddWindow(self.staticText1, 0, border=0, flag=0)
            parent.AddWindow(self.textCtrl1, 0, border=0, flag=0)
        def _init_coll_staticBoxSizer1_Items(self, parent):
            # generated method, don't edit
            parent.AddSizer(self.flexGridSizer1, 0, border=0, flag=0)
        def _init_coll_boxSizer1_Items(self, parent):
            # generated method, don't edit
            parent.AddSizer(self.staticBoxSizer1, 0, border=0, flag=0)
        def _init_sizers(self):
            # generated method, don't edit
            self.staticBoxSizer1 = wx.StaticBoxSizer(box=self.staticBox1,
            self.flexGridSizer1 = wx.FlexGridSizer(cols=0, hgap=0, rows=1, vgap=0)
            self.boxSizer1 = wx.BoxSizer(orient=wx.VERTICAL)
        def _init_ctrls(self, prnt):
            # generated method, don't edit
            wx.Dialog.__init__(self, id=wxID_DIALOG1, name='', parent=prnt,
                  pos=wx.Point(729, 393), size=wx.Size(400, 250),
                  style=wx.DEFAULT_DIALOG_STYLE, title='Dialog1')
            self.SetClientSize(wx.Size(384, 212))
            self.staticBox1 = wx.StaticBox(id=wxID_DIALOG1STATICBOX1,
                  label='staticBox1', name='staticBox1', parent=self,
                  pos=wx.Point(0, 0), size=wx.Size(34, 46), style=0)
            self.staticText1 = wx.StaticText(id=wxID_DIALOG1STATICTEXT1,
                  label='staticText1', name='staticText1', parent=self,
                  pos=wx.Point(0, 0), size=wx.Size(55, 13), style=0)
            self.textCtrl1 = wx.TextCtrl(id=wxID_DIALOG1TEXTCTRL1, name='textCtrl1',
                  parent=self, pos=wx.Point(55, 0), size=wx.Size(100, 21), style=0,
        def __init__(self, parent):
    if __name__ == '__main__':
        app = wx.PySimpleApp()
        dlg = create(None)
  • Carla Chua

    Carla Chua - 2011-01-22

    Thank you very much~ :D


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks