user1032355
user1032355

Reputation: 355

wxPython Splitter windows and Panels

I'm trying to construct a file selector using 2 GenericDirCtrl which display the files in the selected direcotry beneath them. My question is it better to place the splitter window as a child of the frame and add the Panel containing the control to the splitter window or embed the splitter window in a panel with the panel child of the frame?

Upvotes: 0

Views: 5448

Answers (1)

Mike Driscoll
Mike Driscoll

Reputation: 33111

When I used a SplitterWindow, I put it on the frame and gave each side their own panel. But you should be able to do: Frame, Panel, SplitterWindow just as easily.

Here's a generic example:

import wx
import wx.grid as gridlib

########################################################################
class LeftPanel(wx.Panel):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)

        grid = gridlib.Grid(self)
        grid.CreateGrid(25,12)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(grid, 0, wx.EXPAND)
        self.SetSizer(sizer)

########################################################################
class RightPanel(wx.Panel):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)
        txt = wx.TextCtrl(self)


class MyForm(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, "Splitter Tutorial")

        splitter = wx.SplitterWindow(self)
        leftP = LeftPanel(splitter)
        rightP = RightPanel(splitter)

        # split the window
        splitter.SplitVertically(leftP, rightP)
        splitter.SetMinimumPaneSize(20)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splitter, 1, wx.EXPAND)
        self.SetSizer(sizer)

# Run the program
if __name__ == "__main__":
    app = wx.App(False)
    frame = MyForm()
    frame.Show()
    app.MainLoop()

Upvotes: 1

Related Questions