Hi there!
I am having a problem putting a wx.ListCtrl inside a wx.StaticBox. I have a panel with two lists side-by-side, which displays fine, but then I wanted to put a border around each with a descriptive text, and apparently that can be done by using a StaticBox and putting the control inside.
However, as you can see from the screenshot, the list on the left, which has been placed inside a StaticBox, does not stay inside the box, nor is it sized properly. (Without the box, it fills the left half of its sizer, like the list on the right).
This is the code for building the UI (self here is a wx.Frame):
def init_ui(self):
self.panel1 = wx.Panel(self)
self.text1 = wx.TextCtrl(self.panel1)
self.text2 = wx.TextCtrl(self.panel1)
# Set up Groups List
self.sbox1 = wx.StaticBox(self.panel1, wx.ID_ANY, "Groups")
self.list1 = wx.ListCtrl(self.sbox1, id=wx.ID_ANY, style=wx.LC_REPORT)
self.list1.InsertColumn(2, 'Group')
self.list1.InsertColumn(3, 'Description')
# Codes List
self.list2 = wx.ListCtrl(self.panel1, id=wx.ID_ANY, style=wx.LC_REPORT)
self.list2.InsertColumn(2, 'Code')
self.list2.InsertColumn(3, 'Description')
self.sizer0 = wx.BoxSizer(wx.VERTICAL)
self.sizer1 = wx.BoxSizer(wx.HORIZONTAL)
self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)
self.panel1.SetSizer(self.sizer0)
self.sizer0.Add(self.sizer2, 0, flag=wx.ALL | wx.EXPAND, border=5)
self.sizer0.Add(self.sizer1, 1, flag=wx.ALL | wx.EXPAND, border=5)
self.sizer2.Add(self.text1, 0, flag=wx.ALL, border=5)
self.sizer2.Add(self.text2, 0, flag=wx.ALL, border=5)
self.sizer1.Add(self.sbox1, 1, flag=wx.ALL | wx.EXPAND, border=5)
self.sizer1.Add(self.list2, 1, flag=wx.ALL | wx.EXPAND, border=5)