X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3a9604b42b150d20382faa819ffdf38c3bba33b6..0cdd86d6d0c7c9ef37245735703fbc3b420b4c65:/wxPython/wx/lib/splitter.py diff --git a/wxPython/wx/lib/splitter.py b/wxPython/wx/lib/splitter.py index a0d7bfb0f7..68d3cfade3 100644 --- a/wxPython/wx/lib/splitter.py +++ b/wxPython/wx/lib/splitter.py @@ -1,7 +1,7 @@ #---------------------------------------------------------------------- # Name: wx.lib.splitter # Purpose: A class similar to wx.SplitterWindow but that allows more -# a single split +# than a single split # # Author: Robin Dunn # @@ -17,7 +17,6 @@ more than once. """ import wx -import sys _RENDER_VER = (2,6,1,1) @@ -29,7 +28,7 @@ class MultiSplitterWindow(wx.PyPanel): allows for more than two windows and more than one sash. Many of the same styles, constants, and methods behave the same as in wx.SplitterWindow. The key differences are seen in the methods - that deal with the child windows manage by the splitter, and also + that deal with the child windows managed by the splitter, and also those that deal with the sash positions. In most cases you will need to pass an index value to tell the class which window or sash you are refering to. @@ -38,7 +37,7 @@ class MultiSplitterWindow(wx.PyPanel): wx.SplitterWindow. Since the wx.Splitterwindow has only one sash you can think of it's position as either relative to the whole splitter window, or as relative to the first window pane managed - by the splitter. Once there are more than one sash then the + by the splitter. Once there is more than one sash then the distinciton between the two concepts needs to be clairified. I've chosen to use the second definition, and sash positions are the distance (either horizontally or vertically) from the origin of @@ -130,13 +129,17 @@ class MultiSplitterWindow(wx.PyPanel): def AppendWindow(self, window, sashPos=-1): """ - Add a new window to the splitter. If sashPos is given then it is the + Add a new window to the splitter at the right side or bottom + of the window stack. If sashPos is given then it is used to + size the new window. """ - self.InsertWindow(sys.maxint, window, sashPos) + self.InsertWindow(len(self._windows), window, sashPos) def InsertWindow(self, idx, window, sashPos=-1): """ + Insert a new window into the splitter at the position given in + ``idx``. """ assert window not in self._windows, "A window can only be in the splitter once!" self._windows.insert(idx, window) @@ -689,8 +692,7 @@ class MultiSplitterWindow(wx.PyPanel): cw - 2*border, ch - 2*border) else: if 'wxMSW' in wx.PlatformInfo: - for win in self._windows: - win.Freeze() + self.Freeze() if self._orient == wx.HORIZONTAL: x = y = border h = ch - 2*border @@ -714,8 +716,7 @@ class MultiSplitterWindow(wx.PyPanel): if last > 0: self._sashes[idx+1] = last if 'wxMSW' in wx.PlatformInfo: - for win in self._windows: - win.Thaw() + self.Thaw() self._DrawSash(wx.ClientDC(self)) self._needUpdating = False @@ -768,62 +769,3 @@ class MultiSplitterEvent(wx.PyCommandEvent): - -if __name__ == "__main__": - - def OnChanged(evt): - print "Changed:", evt.GetSashIdx(), evt.GetSashPosition() - def OnChanging(evt): - print "Changing:", evt.GetSashIdx(), evt.GetSashPosition() - - - app = wx.App(0) - frm = wx.Frame(None, title="tester", size=(640,480)) - - #frm.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, OnChanged) - #frm.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, OnChanging) - - #sty = 0 - #sty = wx.SP_3DBORDER - #sty = wx.SP_NOSASH - sty = wx.SP_LIVE_UPDATE - - splitter = MultiSplitterWindow(frm, style=sty) - #splitter.SetOrientation(wx.VERTICAL) - splitter.SetMinimumPaneSize(25) - - #sty = wx.BORDER_NONE - #sty = wx.BORDER_SIMPLE - sty = wx.BORDER_SUNKEN - - p1 = wx.Window(splitter, style=sty) - p1.SetBackgroundColour("pink") - wx.StaticText(p1, -1, "Panel One", (5,5)) - - p2 = wx.Window(splitter, style=sty) - p2.SetBackgroundColour("sky blue") - wx.StaticText(p2, -1, "Panel Two", (5,5)) - p2.SetMinSize((50,50)) - - p3 = wx.Window(splitter, style=sty) - p3.SetBackgroundColour("yellow") - wx.StaticText(p3, -1, "Panel Three", (5,5)) - - splitter.AppendWindow(p1, 100) - splitter.AppendWindow(p2, 200) - splitter.AppendWindow(p3) - - for x in range(3): - p = wx.Window(splitter, style=sty) - p.SetBackgroundColour("white") - wx.StaticText(p, -1, str(4+x), (5,5)) - splitter.AppendWindow(p, 50) - - #sizer = wx.BoxSizer() - #sizer.Add(splitter, 1, wx.EXPAND) - #frm.SetSizerAndFit(sizer) - - frm.Show() - app.MainLoop() - -