dabo Commit
Revision 6785
Date: 2011-08-17 07:47:14 -0700 (Wed, 17 Aug 2011)
Author: Jacekk
Trac: http://trac.dabodev.com/changeset/6785

Changed:
U   trunk/dabo/ui/uiwx/dBorderlessButton.py

Log:
Updated ButtonShape property code.

Diff:
Modified: trunk/dabo/ui/uiwx/dBorderlessButton.py
===================================================================
--- trunk/dabo/ui/uiwx/dBorderlessButton.py     2011-08-16 13:21:15 UTC (rev 
6784)
+++ trunk/dabo/ui/uiwx/dBorderlessButton.py     2011-08-17 14:47:14 UTC (rev 
6785)
@@ -46,10 +46,6 @@
                # On some platforms, we need to add some 'breathing room'
                # around the bitmap image in order for it to appear correctly
                self._bmpBorder = 10
-               self._buttonShape = self._extractKey((kwargs, properties, 
attProperties),
-                       "ButtonShape", "Normal")
-               kwargs["style"] = kwargs.get("style", 0) | \
-                       {"n": platebtn.PB_STYLE_DEFAULT, "s": 
platebtn.PB_STYLE_SQUARE}[self._buttonShape[0].lower()]
 
                cm.dControlMixin.__init__(self, preClass, parent, 
properties=properties,
                                attProperties=attProperties, *args, **kwargs)
@@ -63,6 +59,11 @@
                self.Bind(wx.EVT_LEFT_UP, self._onWxHit)
 
 
+       def _getInitPropertiesList(self):
+               return super(dBorderlessButton, self)._getInitPropertiesList() 
+ \
+                       ("ButtonShape",)
+
+
        # Property getters and setters
        def _getBackColorHover(self):
                return self._backColorHover
@@ -81,9 +82,22 @@
 
 
        def _getButtonShape(self):
-               return {"n": "Normal", "s": "Square"}[self._buttonShape[0]]
+               if self._hasWindowStyleFlag(platebtn.PB_STYLE_SQUARE):
+                       return "Square"
+               else:
+                       return "Normal"
 
+       def _setButtonShape(self, val):
+               sst = val[:1].lower()
+               if sst == "s":
+                       self._addWindowStyleFlag(platebtn.PB_STYLE_SQUARE)
+               elif sst in ("n", "r"):
+                       self._delWindowStyleFlag(platebtn.PB_STYLE_SQUARE)
+               else:
+                       raise ValueError(_("Invalid value of %s.ButtonShape 
property: %s") % \
+                               (self.Name, val))
 
+
        def _getCancelButton(self):
                # need to implement
                return False
@@ -141,11 +155,11 @@
        Bitmap = property(_getNormalBitmap, None, None,
                _("""The bitmap normally displayed on the button.  
(wx.Bitmap)"""))
 
-       ButtonShape = property(_getButtonShape, None,
+       ButtonShape = property(_getButtonShape, _setButtonShape,
                _("""Shape of the button. (str)
                
-               Normal  :       button with rounded corners. (default)
-               Square  :       button with square corners."""))
+               Normal/Rounded  :       button with rounded corners. (default)
+               Square                  :       button with square corners."""))
 
        Picture = property(_getNormalPicture, _setNormalPicture, None,
                _("""Specifies the image normally displayed on the button. 
(str)"""))



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to