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()