The StaticBox MUST be created before any of its siblings are created.
···
On Mon, Jun 2, 2008 at 10:31 AM, Mike Rooney mxr@qvii.com wrote:
Hello,
I am having an issue where I create a StaticBox, but the elements inside are unresponsive depending on the parenting of the StaticBox[Sizer]. Please see the attached runnable demo.
You will note it opens two (seemingly) identical frames. In the first one, the checkbox in the StaticBox does not work. In the second, it works fine. In either case, the bottom checkbox always works, so it is just the control in the StaticBox that is the issue.
I initially noticed this behavior on OSX (wx 2.8.4.0) but when making this test was able to duplicate it on XP as well (wx 2.8.7.1). Can anyone else confirm or deny the unresponsive checkbox in the “Frozen StaticBox”-titled frame within the StaticBox?
What am I doing wrong in making my custom control and how can I get it to work within that context? I spent a decent amount of time making this demo and reducing a custom control of hundreds of lines down to the tiny AccountListCtrl in the attached file, so I would really appreciate a response and some assistance.
Thanks!
Mike Rooney
import wx
class AccountListCtrl(wx.Panel):
def __init__(self, parent): wx.Panel.__init__(self, parent) self.staticBox = wx.StaticBox(self, label="Controls") self.Sizer = wx.StaticBoxSizer(self.staticBox, wx.VERTICAL) self.Sizer.Add(wx.CheckBox(self, label="CheckBox"), 0, wx.TOP, 10) self.Sizer.Layout()
class TestFrame1(wx.Frame):
def __init__(self, parent=None): wx.Frame.__init__(self, parent, title="Frozen StaticBox", pos=(100,100)) panel = wx.Panel(self) panel.Sizer = wx.BoxSizer(wx.VERTICAL) panel.Sizer.Add(AccountListCtrl(self), 1, wx.EXPAND) #frozen? panel.Sizer.Add(wx.CheckBox(panel), 0, wx.ALIGN_CENTER) #works fine self.Sizer = wx.BoxSizer() self.Sizer.Add(panel, 1, wx.EXPAND) self.Sizer.Layout()
class TestFrame2(wx.Frame):
def __init__(self, parent=None): wx.Frame.__init__(self, parent, title="Working StaticBox", pos=(100,400)) panel = wx.Panel(self) staticBox = wx.StaticBox(panel, label="Controls") sbSizer = wx.StaticBoxSizer(staticBox, wx.VERTICAL) sbSizer.Add(wx.CheckBox(panel, label="CheckBox"), 0, wx.TOP, 10) panel.Sizer = wx.BoxSizer(wx.VERTICAL) panel.Sizer.Add(sbSizer, 1, wx.EXPAND) #frozen? panel.Sizer.Add(wx.CheckBox(panel), 0, wx.ALIGN_CENTER) #works fine self.Sizer = wx.BoxSizer() self.Sizer.Add(panel, 1, wx.EXPAND) self.Sizer.Layout()
if name == “main”:
app = wx.App(False) frame1 = TestFrame1().Show(True) frame1 = TestFrame2().Show(True) app.MainLoop()
__
–
Stand Fast,
tjg.