dabo Commit
Revision 2157
Date: 2006-05-16 13:11:00 -0700 (Tue, 16 May 2006)
Author: ed

Changed:
U   trunk/dabo/ui/uiwx/dRadioList.py
U   trunk/dabo/ui/uiwx/dSizerMixin.py

Log:
Added the 'ButtonSpacing' property to dRadioList. It controls the amount of 
space between buttons. Updated dSizerMixin to provide additional support for 
spacer manipulation.


Diff:
Modified: trunk/dabo/ui/uiwx/dRadioList.py
===================================================================
--- trunk/dabo/ui/uiwx/dRadioList.py    2006-05-16 19:51:07 UTC (rev 2156)
+++ trunk/dabo/ui/uiwx/dRadioList.py    2006-05-16 20:11:00 UTC (rev 2157)
@@ -42,6 +42,9 @@
                # Tracks individual member radio buttons.
                self._items = []
                self._selpos = 0
+               # Default spacing between buttons. Can be changed with the
+               # 'ButtonSpacing' property.
+               self._buttonSpacing = 5
 
                cim.dControlItemMixin.__init__(self, preClass, parent, 
properties, *args, **kwargs)
 
@@ -156,6 +159,19 @@
                
        # Property get/set/del methods follow. Scroll to bottom to see the 
property
        # definitions themselves.
+       def _getButtonSpacing(self):
+               return self._buttonSpacing
+               
+       def _setButtonSpacing(self, val):
+               self._buttonSpacing = val
+               for itm in self.Sizer.ChildSpacers:
+                       self.Sizer.setItemProp(itm, "Spacing", val)
+               try:
+                       self.Parent.layout()
+               except:
+                       self.layout()
+                       
+                       
        def _getCaption(self):
                ret = ""
                if isinstance(self.Sizer, dabo.ui.dBorderSizer):
@@ -184,7 +200,12 @@
                        [itm.release() for itm in self._items]
                        self._choices = choices
                        self._items = []
+                       first = True
                        for itm in choices:
+                               if first:
+                                       first = False
+                               else:
+                                       
self.Sizer.appendSpacer(self._buttonSpacing)
                                btn = _dRadioButton(self, Caption=itm)
                                self.Sizer.append(btn)
                                self._items.append(btn)
@@ -246,6 +267,9 @@
        
        
        # Property definitions:
+       ButtonSpacing = property(_getButtonSpacing, _setButtonSpacing, None,
+                       _("Spacing in pixels between buttons in the control  
(int)"))
+                       
        Caption = property(_getCaption, _setCaption, None,
                        _("String to display on the box surrounding the control 
 (str)"))
        

Modified: trunk/dabo/ui/uiwx/dSizerMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dSizerMixin.py   2006-05-16 19:51:07 UTC (rev 2156)
+++ trunk/dabo/ui/uiwx/dSizerMixin.py   2006-05-16 20:11:00 UTC (rev 2157)
@@ -178,17 +178,12 @@
        def addSpacer(self, val, pos=None, proportion=0):
                spacer = val
                if isinstance(val, int):
-                       if self.Orientation == "Vertical":
-                               spacer = (1, val)
-                       elif self.Orientation == "Horizontal":
-                               spacer = (val, 1)
-                       else:
-                               # Something's up; bail out
-                               return
+                       spacer = (val, val)
                if pos is None:
                        itm = self.Add(spacer, proportion=proportion, 
userData=self)
                else:
                        itm = self.Insert(pos, spacer, proportion=proportion, 
userData=self)
+               itm.setSpacing = itm.SetSpacer
                return itm
        
        
@@ -215,8 +210,8 @@
                spc = self.DefaultSpacing
                if spc:
                        self.addSpacer(spc, pos)
-                               
        
+       
        def getItem(self, szItem):
                """Querying sizers for their contents returns sizer items, not
                the actual items. So given a sizer item, this method will return
@@ -365,6 +360,13 @@
                        ret = self.setRowSpan(itm, val)
                elif lowprop == "colspan" and isinstance(self, 
dabo.ui.dGridSizer):
                        ret = self.setColSpan(itm, val)
+               elif lowprop == "spacing":
+                       if isinstance(val, int):
+                               val = (val, val)
+                       try:
+                               ret = itm.SetSpacer(val)
+                               ret = True
+                       except: pass
                elif lowprop in ("expand", "halign", "valign", "bordersides"):
                        ret = True
                        pd = {"left" : self.leftFlag, 
@@ -589,6 +591,21 @@
                return ret
        
        
+       def _getChildSpacers(self):
+               itms = self.GetChildren()
+               ret = [itm for itm in itms
+                               if itm.IsSpacer() ]
+               return ret
+       
+       
+       def _getChildSizers(self):
+               itms = self.GetChildren()
+               ret = [itm.GetSizer()
+                               for itm in itms
+                               if itm.IsSizer() ]
+               return ret
+       
+       
        def _getChildWindows(self):
                itms = self.GetChildren()
                ret = [itm.GetWindow()
@@ -757,6 +774,12 @@
        Children = property(_getChildren, None, None, 
                        _("List of all the sizer items managed by this sizer  
(list of sizerItems" ) )
        
+       ChildSizers = property(_getChildSizers, None, None, 
+                       _("List of all the sizers that are directly managed by 
this sizer  (list of sizers" ) )
+       
+       ChildSpacers = property(_getChildSpacers, None, None, 
+                       _("List of all the spacer items that are directly 
managed by this sizer  (list of spacer items" ) )
+       
        ChildWindows = property(_getChildWindows, None, None, 
                        _("List of all the windows that are directly managed by 
this sizer  (list of controls" ) )
        




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to