Changeset 4064

Show
Ignore:
Timestamp:
05/04/08 13:04:33 (2 months ago)
Author:
ed
Message:

Added an explicit 'Splitter' property, as I found some edge cases where there was not yet a splitter created when attempting to set props after self.constructed() returned True. Now the Splitter prop will create the splitter the first time it is referenced.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/ui/uiwx/dSplitForm.py

    r3303 r4064  
    1010 
    1111class dSplitForm(dabo.ui.dForm): 
    12     def _afterInit(self): 
    13         win = self.splitter = dSplitter(self, createPanes=True, RegID="MainSplitter") 
    14         super(dSplitForm, self)._afterInit() 
    15         self.Sizer.append1x(win) 
    16         win.Visible = True 
    17         self.layout() 
     12    def __init__(self, *args, **kwargs): 
     13        self._splitter = None 
     14        super(dSplitForm, self).__init__(*args, **kwargs) 
    1815 
    1916 
    2017    def unsplit(self): 
    21         self.splitter.unsplit() 
     18        self.Splitter.unsplit() 
    2219         
    2320     
    2421    def split(self, dir=None): 
    25         self.splitter.split(dir) 
     22        self.Splitter.split(dir) 
    2623         
    2724 
    2825    def _getMinPanelSize(self): 
    29         return self.splitter.MinPanelSize 
     26        return self.Splitter.MinPanelSize 
    3027         
    3128    def _setMinPanelSize(self, val): 
    3229        if self._constructed(): 
    33             self.splitter.MinPanelSize = val 
     30            self.Splitter.MinPanelSize = val 
    3431        else: 
    3532            self._properties["MinPanelSize"] = val 
     
    3734     
    3835    def _getOrientation(self): 
    39         return self.splitter.Orientation 
     36        return self.Splitter.Orientation 
    4037         
    4138    def _setOrientation(self, val): 
    4239        if self._constructed(): 
    43             self.splitter.Orientation = val 
     40            self.Splitter.Orientation = val 
    4441        else: 
    4542            self._properties["MinPanelSize"] = val 
     
    4744     
    4845    def _getPanel1(self): 
    49         return self.splitter.Panel1 
     46        return self.Splitter.Panel1 
    5047         
    5148    def _setPanel1(self, pnl): 
    5249        if self._constructed(): 
    53             self.splitter.Panel1 = pnl 
     50            self.Splitter.Panel1 = pnl 
    5451        else: 
    5552            self._properties["Panel1"] = pnl 
     
    5754 
    5855    def _getPanel2(self): 
    59         return self.splitter.Panel2 
     56        return self.Splitter.Panel2 
    6057         
    6158    def _setPanel2(self, pnl): 
    6259        if self._constructed(): 
    63             self.splitter.Panel2 = pnl 
     60            self.Splitter.Panel2 = pnl 
    6461        else: 
    6562            self._properties["Panel2"] = pnl 
     
    6764     
    6865    def _getSashPosition(self): 
    69         return self.splitter.SashPosition 
     66        return self.Splitter.SashPosition 
    7067         
    7168    def _setSashPosition(self, val): 
    7269        if self._constructed(): 
    73             self.splitter.SashPosition = val 
     70            self.Splitter.SashPosition = val 
    7471        else: 
    7572            self._properties["SashPosition"] = val 
    7673         
    77      
     74 
     75    def _getSplitter(self): 
     76        if self._splitter is None: 
     77            win = self._splitter = dSplitter(self, createPanes=True, RegID="MainSplitter") 
     78            def addToSizer(frm, itm): 
     79                if not frm.Sizer: 
     80                    dabo.ui.callAfter(addToSizer, frm, itm) 
     81                else: 
     82                    frm.Sizer.append1x(itm) 
     83                    frm.layout() 
     84            win.Visible = True 
     85            dabo.ui.callAfter(addToSizer, self, win) 
     86        return self._splitter 
     87 
     88 
    7889 
    7990    MinPanelSize = property(_getMinPanelSize, _setMinPanelSize, None, 
    8091            _("Controls the minimum width/height of the panels.  (int)")) 
    81     DynamicMinPanelSize = makeDynamicProperty(MinPanelSize) 
    8292             
    8393    Orientation = property(_getOrientation, _setOrientation, None, 
    8494            _("Determines if the window splits Horizontally or Vertically.  (str)")) 
    85     DynamicOrientation = makeDynamicProperty(Orientation) 
    8695             
    8796    Panel1 = property(_getPanel1, _setPanel1, None, 
     
    93102    SashPosition = property(_getSashPosition, _setSashPosition, None, 
    94103            _("Position of the sash when the window is split.  (int)")) 
     104 
     105    Splitter = property(_getSplitter, None, None, 
     106            _("Reference to the main splitter in the form  (dSplitter")) 
     107 
     108 
     109 
     110    DynamicMinPanelSize = makeDynamicProperty(MinPanelSize) 
     111    DynamicOrientation = makeDynamicProperty(Orientation) 
    95112    DynamicSashPosition = makeDynamicProperty(SashPosition) 
    96  
    97113 
    98114 
     
    102118 
    103119    def afterInit(self): 
    104         self.splitter.Panel1.BackColor = dabo.dColors.randomColor() 
    105         self.splitter.Panel2.BackColor = dabo.dColors.randomColor() 
     120        self.Splitter.Panel1.BackColor = dabo.dColors.randomColor() 
     121        self.Splitter.Panel2.BackColor = dabo.dColors.randomColor() 
    106122         
    107123