dabo Commit
Revision 3183
Date: 2007-06-19 09:03:37 -0700 (Tue, 19 Jun 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/3183

Changed:
U   trunk/dabo/ui/uiwx/dDataControlMixin.py
U   trunk/dabo/ui/uiwx/dTextBoxMixin.py

Log:
Updated both to use the new ChangeValue() method to set the wx-level value when 
it is available. This change will allow the controls to work with both newer 
versions of wxPython, in which SetValue() is deprecated, and older ones, which 
only support SetValue().


Diff:
Modified: trunk/dabo/ui/uiwx/dDataControlMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dDataControlMixin.py     2007-06-19 15:50:12 UTC (rev 
3182)
+++ trunk/dabo/ui/uiwx/dDataControlMixin.py     2007-06-19 16:03:37 UTC (rev 
3183)
@@ -72,8 +72,11 @@
                        if type(self.Value) != type(val):
                                val = self._coerceValue(val, self.Value)
                        if (type(self.Value) != type(val) or self.Value != val):
+                               setter = self.SetValue
+                               if hasattr(self, "ChangeValue"):
+                                       setter = self.ChangeValue
                                try:
-                                       self.SetValue(val)
+                                       setter(val)
                                except TypeError, e:
                                        dabo.errorLog.write(_("Could not set 
value of %s to %s. Error message: %s")
                                                        % (self._name, val, e))

Modified: trunk/dabo/ui/uiwx/dTextBoxMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dTextBoxMixin.py 2007-06-19 15:50:12 UTC (rev 3182)
+++ trunk/dabo/ui/uiwx/dTextBoxMixin.py 2007-06-19 16:03:37 UTC (rev 3183)
@@ -41,7 +41,10 @@
                # must save and restore the InsertionPosition because wxGtk at 
least resets it to
                # 0 upon SetValue().
                insPos = self.InsertionPosition
-               self.SetValue(self.getStringValue(self.Value))
+               setter = self.SetValue
+               if hasattr(self, "ChangeValue"):
+                       setter = self.ChangeValue
+               setter(self.getStringValue(self.Value))
                self.InsertionPosition = insPos
                
                # Now that the dabo Value is set properly, the default behavior 
that flushes 
@@ -278,10 +281,13 @@
        
        def _setValue(self, val):
                if self._constructed():
+                       setter = self.SetValue
+                       if hasattr(self, "ChangeValue"):
+                               setter = self.ChangeValue
                        if self._inForceCase:
                                # Value is changing internally. Don't update 
the oldval
                                # setting or change the type; just set the 
value.
-                               self.SetValue(val)
+                               setter(val)
                                return
                        else:
                                dabo.ui.callAfter(self._checkForceCase)
@@ -289,7 +295,7 @@
                        if self._inTextLength:
                                # Value is changing internally. Don't update 
the oldval
                                # setting or change the type; just set the 
value.
-                               self.SetValue(val)
+                               setter(val)
                                return
                        else:
                                dabo.ui.callAfter(self._checkTextLength)
@@ -304,7 +310,7 @@
                        self._value = val
 
                        # Update the display no matter what:
-                       self.SetValue(strVal)
+                       setter(strVal)
                
                        if type(_oldVal) != type(val) or _oldVal != val:
                                self._afterValueChanged()               
@@ -579,6 +585,12 @@
                        # Must convert all to string for sending to wx, but our 
internal 
                        # _value will always retain the correct type.
                        
+                       # TextCtrls in wxPython since 2.7 have a ChangeValue() 
method that is to 
+                       # be used instead of the old SetValue().
+                       setter = self.SetValue
+                       if hasattr(self, "ChangeValue"):
+                               setter = self.ChangeValue
+
                        # Todo: set up validators based on the type of data we 
are editing,
                        # so the user can't, for example, enter a letter "p" in 
a textbox
                        # that is currently showing numeric data.
@@ -586,7 +598,7 @@
                        if self._inForceCase:
                                # Value is changing internally. Don't update 
the oldval
                                # setting or change the type; just set the 
value.
-                               self.SetValue(val)
+                               setter(val)
                                return
                        else:
                                dabo.ui.callAfter(self._checkForceCase)
@@ -594,7 +606,7 @@
                        if self._inTextLength:
                                # Value is changing internally. Don't update 
the oldval
                                # setting or change the type; just set the 
value.
-                               self.SetValue(val)
+                               setter(val)
                                return
                        else:
                                dabo.ui.callAfter(self._checkTextLength)
@@ -611,7 +623,7 @@
                                self._lastDataType = type(val)
 
                        # Update the display no matter what:
-                       self.SetValue(strVal)
+                       setter(strVal)
                
                        if type(_oldVal) != type(val) or _oldVal != val:
                                self._afterValueChanged()




_______________________________________________
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/dabo-dev/[EMAIL PROTECTED]

Reply via email to