Nested Sizer/checkbox problem

Hi All,
I was trying to investigate StaticBoxSizer ReLayout when my test program stops activating the CheckBox inside the StaticBoxSizer. The CheckBox outside the StaticBox is OK. Please can somebody tell me what is wrong, I am sure it is something simle. It is a short complete example program below, please click each CheckBox.

Thanks

Nigel King

import wx
class MainWindow(wx.Frame):
     """ We simply derive a new class of Frame. """
     def __init__(self, parent, id, name):
         wx.Frame.__init__(self, parent, -1, name)

         st = wx.StaticText(self, -1, "This example demonstrates resizing of wx.StaticBox \nand showing and hiding an object.")

         self.cb1 = wx.CheckBox(self, -1, "StaticBox On/Off Control")

         self.cb2 = wx.CheckBox(self, -1, "Ordinary Checkbox")
         self.cb3 = wx.CheckBox(self, -1, "On/Off enabled checkbox")
         self.cb3.Show(False)
         self.cb4 = wx.CheckBox(self, -1, "This one stays on")

         self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, self.cb1)
         self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, self.cb2)
         self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, self.cb3)
         self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, self.cb4)

         box_title = wx.StaticBox(self, -1, "Box Title")
         sbSizer = wx.StaticBoxSizer(box_title, wx.VERTICAL)
         sbSizer.AddMany([self.cb2, self.cb3, self.cb4])

         border = wx.BoxSizer(wx.VERTICAL)
         border.Add(st, 0, wx.ALL, 15)
         border.Add(self.cb1, 0, wx.LEFT, 61)
         border.Add(sbSizer, 0, wx.LEFT, 50)

         self.SetSizer(border)
         self.Show(True)

     def EvtCheckBox(self, event):
         print ('EvtCheckBox: %d Id: %d' % (event.IsChecked(), event.GetId()))
         if event.GetId() == self.cb1.GetId():
             self.cb3.Show(event.IsChecked())
             self.Layout()

app = wx.PySimpleApp()

frame=MainWindow(None, -1, 'Test StaticBoxSizer')
app.MainLoop()

Hi again,
You must have been bemused by this one. It is a Mac only fault I think. My Virtual PC and my Son's PC both work but on my Mac using python 2.3 and wxPython 2.6.0.1, the checkboxes in the StaticBoxSizer fail to check or uncheck. I will pass this to the Mac List as well.

Nigel King

···

On 9 Sep 2005, at 00:09, Nigel King wrote:

Hi All,
I was trying to investigate StaticBoxSizer ReLayout when my test program stops activating the CheckBox inside the StaticBoxSizer. The CheckBox outside the StaticBox is OK. Please can somebody tell me what is wrong, I am sure it is something simle. It is a short complete example program below, please click each CheckBox.

Thanks

Nigel King

import wx
class MainWindow(wx.Frame):
    """ We simply derive a new class of Frame. """
    def __init__(self, parent, id, name):
        wx.Frame.__init__(self, parent, -1, name)

        st = wx.StaticText(self, -1, "This example demonstrates resizing of wx.StaticBox \nand showing and hiding an object.")

        self.cb1 = wx.CheckBox(self, -1, "StaticBox On/Off Control")

        self.cb2 = wx.CheckBox(self, -1, "Ordinary Checkbox")
        self.cb3 = wx.CheckBox(self, -1, "On/Off enabled checkbox")
        self.cb3.Show(False)
        self.cb4 = wx.CheckBox(self, -1, "This one stays on")

        self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, self.cb1)
        self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, self.cb2)
        self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, self.cb3)
        self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, self.cb4)

        box_title = wx.StaticBox(self, -1, "Box Title")
        sbSizer = wx.StaticBoxSizer(box_title, wx.VERTICAL)
        sbSizer.AddMany([self.cb2, self.cb3, self.cb4])

        border = wx.BoxSizer(wx.VERTICAL)
        border.Add(st, 0, wx.ALL, 15)
        border.Add(self.cb1, 0, wx.LEFT, 61)
        border.Add(sbSizer, 0, wx.LEFT, 50)

        self.SetSizer(border)
        self.Show(True)

    def EvtCheckBox(self, event):
        print ('EvtCheckBox: %d Id: %d' % (event.IsChecked(), event.GetId()))
        if event.GetId() == self.cb1.GetId():
            self.cb3.Show(event.IsChecked())
            self.Layout()

app = wx.PySimpleApp()

frame=MainWindow(None, -1, 'Test StaticBoxSizer')
app.MainLoop()

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

*From:* Nigel King <King@dircon.co.uk>
*To:* wxPython-users@lists.wxwidgets.org
*Date:* Fri, 9 Sep 2005 00:09:24 +0100

Hi All,
I was trying to investigate StaticBoxSizer ReLayout when my test
program stops activating the CheckBox inside the StaticBoxSizer. The
CheckBox outside the StaticBox is OK. Please can somebody tell me what
is wrong, I am sure it is something simle. It is a short complete
example program below, please click each CheckBox.

Thanks

Nigel King

Nigel, your example doesn't work on the Mac for me either. I have
recreated your test case using wxDesigner, which looks after all the
sizers automatically via a GUI. The generated code is attached, and this
works OK. I haven't investigated any further, but it should be a fairly
simple process of elimination.

Regards,

David Hughes
Forestfield Software
www.foresoft.co.uk

checkboxtest.py (2.91 KB)

David,
Thanks for responding I used the info supplied by Stefan.
Nigel

···

On 10 Sep 2005, at 08:14, David Hughes wrote:

*From:* Nigel King <King@dircon.co.uk>
*To:* wxPython-users@lists.wxwidgets.org
*Date:* Fri, 9 Sep 2005 00:09:24 +0100

Hi All,
I was trying to investigate StaticBoxSizer ReLayout when my test
program stops activating the CheckBox inside the StaticBoxSizer. The
CheckBox outside the StaticBox is OK. Please can somebody tell me what
is wrong, I am sure it is something simle. It is a short complete
example program below, please click each CheckBox.

Thanks

Nigel King

Nigel, your example doesn't work on the Mac for me either. I have
recreated your test case using wxDesigner, which looks after all the
sizers automatically via a GUI. The generated code is attached, and this
works OK. I haven't investigated any further, but it should be a fairly
simple process of elimination.

Regards,

David Hughes
Forestfield Software
www.foresoft.co.uk<checkboxtest.py>---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org