dabo Commit
Revision 5478
Date: 2009-10-21 15:27:14 -0700 (Wed, 21 Oct 2009)
Author: Paul
Trac: http://trac.dabodev.com/changeset/5478

Changed:
U   trunk/dabo/ui/uiwx/dButton.py
U   trunk/dabo/ui/uiwx/dPemMixin.py

Log:
Did some work getting dButton.CancelButton working, at least on Linux.


Diff:
Modified: trunk/dabo/ui/uiwx/dButton.py
===================================================================
--- trunk/dabo/ui/uiwx/dButton.py       2009-10-21 16:58:41 UTC (rev 5477)
+++ trunk/dabo/ui/uiwx/dButton.py       2009-10-21 22:27:14 UTC (rev 5478)
@@ -46,15 +46,7 @@
        # Property get/set/del methods follow. Scroll to bottom to see the 
property
        # definitions themselves.
        def _getCancelButton(self):
-#              try:
-#                      return self.Parent._acceleratorTable["esc"] == 
self.__onCancelButton
-#              except KeyError:
-#                      return False
-               try:
-                       v = self._cancelButton
-               except AttributeError:
-                       v = self._cancelButton = False
-               return v
+               return self.GetId() == wx.ID_CANCEL
 
 
        def _setCancelButton(self, val):
@@ -68,8 +60,9 @@
                        ##      self.Parent is also a valid choice.
                        ### egl: changed the binding on OS X to the form. 
Parent just doesn't work.
                        ### pkm: followed suit with GTK (we should test Win 
too).
+                       ### pkm: removed GTK to bind to parent because it 
wasn't working on the form.
                        target = self.Parent
-                       if self.Application.Platform in ("Mac", "GTK"):
+                       if self.Application.Platform in ("Mac"):
                                target = self.Form
                        if val:
                                target.bindKey("esc", self.__onCancelButton)
@@ -77,9 +70,14 @@
                        else:
                                target.unbindKey("esc")
                                self.SetId(wx.NewId())
-                       self._cancelButton = val
                else:
-                       self._properties["CancelButton"] = value
+                       # In order to get the stock cancel button behavior from 
the OS, we need
+                       # to set the id here. So, getting the stock button 
behavior must happen
+                       # in the constructor, but theoretically we can get the 
excape behavior
+                       # anytime.
+                       if val:
+                               self._preInitProperties["id"] = wx.ID_CANCEL
+                       self._properties["CancelButton"] = val
 
 
        def _getDefaultButton(self):

Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py     2009-10-21 16:58:41 UTC (rev 5477)
+++ trunk/dabo/ui/uiwx/dPemMixin.py     2009-10-21 22:27:14 UTC (rev 5478)
@@ -346,7 +346,8 @@
                constructor. This tells Dabo which properties to specially 
handle.
                """
                return ("Alignment", "BorderStyle", "ButtonClass", 
"MultipleSelect", 
-                               "Orientation", "PasswordEntry", "ShowLabels", 
"SizerClass", "TabPosition")
+                               "Orientation", "PasswordEntry", "ShowLabels", 
"SizerClass", "TabPosition",
+                               "CancelButton")
                
 
        def _setInitProperties(self, **_properties):




_______________________________________________
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