I'm trying to use wx.Listbook to implement a settings window with multiple pages. I made the Listbook just fine, but when I started adding items to a page, I ran into a problem. The items are displayed on top of each other, so it's impossible to see everything I'm trying to show.
self.global_settings_frame = wx.Frame(parent=self, title="Global Settings", name="Global Settings")
self.global_settings_listbook = wx.Listbook(parent=self.global_settings_frame, style=wx.LB_LEFT)
self.global_settings_file_window = wx.Panel(parent=self.global_settings_listbook)
self.global_settings_file_box = wx.BoxSizer(orient=wx.VERTICAL)
self.show_full_pathname_checkbox = wx.CheckBox(self.global_settings_file_window, label="Show full pathname")
self.global_settings_file_box.Add(self.show_full_pathname_checkbox, proportion=1)
self.global_default_extension = wx.TextCtrl(self.global_settings_file_window)
self.global_settings_file_box.Add(self.global_default_extension, proportion=1)
self.global_settings_token_window = wx.Panel(parent=self.global_settings_listbook)
self.global_settings_listbook.InsertPage(0, self.global_settings_file_window, "Files")
self.global_settings_listbook.InsertPage(1, self.global_settings_token_window, "Token Defnition")
self.global_settings_frame.Show()
When I comment out the second element, the uncommented part works fine:
self.global_settings_frame = wx.Frame(parent=self, title="Global Settings", name="Global Settings")
self.global_settings_listbook = wx.Listbook(parent=self.global_settings_frame, style=wx.LB_LEFT)
self.global_settings_file_window = wx.Panel(parent=self.global_settings_listbook)
self.global_settings_file_box = wx.BoxSizer(orient=wx.VERTICAL)
self.show_full_pathname_checkbox = wx.CheckBox(self.global_settings_file_window, label="Show full pathname")
self.global_settings_file_box.Add(self.show_full_pathname_checkbox, proportion=1)
self.global_default_extension = wx.TextCtrl(self.global_settings_file_window)
self.global_settings_file_box.Add(self.global_default_extension, proportion=1)
self.global_settings_token_window = wx.Panel(parent=self.global_settings_listbook)
self.global_settings_listbook.InsertPage(0, self.global_settings_file_window, "Files")
self.global_settings_listbook.InsertPage(1, self.global_settings_token_window, "Token Defnition")
self.global_settings_frame.Show()
But I think the BoxSizer isn't working right because when I comment out the previous line (the one adding the CheckBox to the BoxSizer), the display is the same.
I've tried using separate panels for each element and then putting those panels in the BoxSizer, but that also didn't work (I can show you what that looks like if necessary). So it looks like I'm not using the BoxSizer correctly, but I don't understand how I am supposed to use it in this case. What I want is a page of a ListBook that contains a CheckBox and a TextCtrl (for single line text entry). Can you help?
As I can see, you never assign any sizer to your page(s).
You should just do it :
......
self.global_settings_file_box.Add(self.global_default_extension, proportion=1)
self.global_settings_file_window.SetSizer(self.global_settings_file_box)
self.global_settings_token_window = wx.Panel(parent=self.global_settings_listbook)
......
Regards Xav'