Search code examples
wxpythonsplitter

wxpython : how to use Spiltter inside the panel with controls?


class PageOneOne(wx.Panel): def init(self, parent): wx.Panel.init(self, parent) splitter = wx.SplitterWindow(self, -1)

    t = self.control = wx.TextCtrl(splitter, 1, style=wx.TE_MULTILINE)

    self.lc = wx.ListCtrl(splitter, -1, style=wx.LC_REPORT)
    self.lc.InsertColumn(0, 'State')
    self.lc.InsertColumn(1, 'Capital')
    self.lc.SetColumnWidth(0, 140)
    self.lc.SetColumnWidth(1, 153)

    vbox = wx.BoxSizer(wx.VERTICAL)
    vbox.Add(splitter, 1, wx.EXPAND)
    self.SetSizer(vbox)
    splitter.SplitHorizontally(t, self.lc, 20)

Solution

  • You cannot use a SplitterWindow with a text control and list control. You have to use it with Panels or Windows. I would recommend using Panels as you really shouldn't use the Window widget directly.

    The Panels may contain the other widgets. So for PanelOne, you would add the text control as its child. Then in PanelTwo, you would create a list control as its child. Then you would call your splitter window's SplitHorizontally(PanelOne, PanelTwo, 20)