dabo Commit
Revision 2935
Date: 2007-03-19 12:47:01 -0700 (Mon, 19 Mar 2007)
Author: Paul
Trac: http://svn.dabodev.com/trac/dabo/changeset/2935
Changed:
U trunk/dabo/ui/dDataControlMixinBase.py
U trunk/dabo/ui/uiwx/dComboBox.py
U trunk/dabo/ui/uiwx/dControlItemMixin.py
U trunk/dabo/ui/uiwx/dDataControlMixin.py
U trunk/dabo/ui/uiwx/dDropdownList.py
U trunk/dabo/ui/uiwx/dRadioList.py
Log:
Fixed some problems with some controls flushing their values too many times,
and raising ValueChanged events too many times (raising it even if the value
didn't change).
This commit should result in better performance, due to multiple events no
longer being called.
Diff:
Modified: trunk/dabo/ui/dDataControlMixinBase.py
===================================================================
--- trunk/dabo/ui/dDataControlMixinBase.py 2007-03-19 18:16:34 UTC (rev
2934)
+++ trunk/dabo/ui/dDataControlMixinBase.py 2007-03-19 19:47:01 UTC (rev
2935)
@@ -159,17 +159,16 @@
""" Save any changes to the underlying source field."""
curVal = self.Value
ret = None
- try:
- oldVal = self._oldVal
- except AttributeError:
- oldVal = None
+ isChanged = False
+ oldVal = self._oldVal
+ if oldVal is None and curVal is None:
+ # Could be changed and we just don't know it...
+ isChanged = True
if isinstance(self, (dabo.ui.dToggleButton,)):
# These classes change their value before the GotFocus
event
# can store the oldval, so always flush 'em.
oldVal = None
- if curVal is None:
- isChanged = True
- else:
+ if not isChanged:
if isinstance(curVal, float) and isinstance(oldVal,
float):
# If it is a float, make sure that it has
changed by more than the
# rounding error.
@@ -219,16 +218,8 @@
else:
nm =
str(self.DataSource)
dabo.errorLog.write("Could not bind to '%s.%s'" % (nm, self.DataField) )
-
+ self._oldVal = curVal
self._afterValueChanged(_from_flushValue=True)
-
- # In most controls, self._oldVal is set upon GotFocus. Some
controls
- # like dCheckBox and dDropdownList don't emit focus events, so
- # flushValue must stand alone (those controls call flushValue()
upon
- # every Hit, while other controls call flushValue() upon
LostFocus.
- # Setting _oldVal to None here ensures that any changes will
get saved
- # no matter what type of control we are...
- self._oldVal = None
return ret
@@ -300,7 +291,7 @@
self._value = self.Value
# Raise an event so that user code can react if needed:
- self.raiseEvent(dabo.dEvents.ValueChanged)
+ dabo.ui.callAfterInterval(200, self.raiseEvent,
dabo.dEvents.ValueChanged)
if not _from_flushValue and self.Form.ActiveControl != self:
# Value was changed programatically - flushValue won't
be called
Modified: trunk/dabo/ui/uiwx/dComboBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dComboBox.py 2007-03-19 18:16:34 UTC (rev 2934)
+++ trunk/dabo/ui/uiwx/dComboBox.py 2007-03-19 19:47:01 UTC (rev 2935)
@@ -34,7 +34,7 @@
def __onComboBox(self, evt):
self._userVal = False
evt.Skip()
- self.raiseEvent(dabo.dEvents.Hit, evt)
+ self._onWxHit(evt)
def __onTextBox(self, evt):
Modified: trunk/dabo/ui/uiwx/dControlItemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dControlItemMixin.py 2007-03-19 18:16:34 UTC (rev
2934)
+++ trunk/dabo/ui/uiwx/dControlItemMixin.py 2007-03-19 19:47:01 UTC (rev
2935)
@@ -21,13 +21,14 @@
def _initEvents(self):
super(dControlItemMixin, self)._initEvents()
- self.bindEvent(dEvents.Hit, self.__flush)
+
-
- def __flush(self, evt):
+ def _onWxHit(self, evt):
+ # Flush value on every hit:
self.flushValue()
+ super(dControlItemMixin, self)._onWxHit(evt)
+
-
def appendItem(self, txt, select=False):
""" Adds a new item to the end of the list """
chc = self._choices
Modified: trunk/dabo/ui/uiwx/dDataControlMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dDataControlMixin.py 2007-03-19 18:16:34 UTC (rev
2934)
+++ trunk/dabo/ui/uiwx/dDataControlMixin.py 2007-03-19 19:47:01 UTC (rev
2935)
@@ -76,7 +76,6 @@
except TypeError, e:
dabo.errorLog.write(_("Could not set
value of %s to %s. Error message: %s")
% (self._name, val, e))
- self._afterValueChanged()
self.flushValue()
else:
self._properties["Value"] = val
Modified: trunk/dabo/ui/uiwx/dDropdownList.py
===================================================================
--- trunk/dabo/ui/uiwx/dDropdownList.py 2007-03-19 18:16:34 UTC (rev 2934)
+++ trunk/dabo/ui/uiwx/dDropdownList.py 2007-03-19 19:47:01 UTC (rev 2935)
@@ -27,14 +27,6 @@
self.Bind(wx.EVT_CHOICE, self._onWxHit)
- def _onWxHit(self, evt):
- # wx.Choice doesn't seem to emit lostfocus and gotfocus events.
Therefore,
- # flush the value on every hit.
- self.flushValue()
- super(dDropdownList, self)._onWxHit(evt)
-
-
-
class _dDropdownList_test(dDropdownList):
def initProperties(self):
# Simulating a database
Modified: trunk/dabo/ui/uiwx/dRadioList.py
===================================================================
--- trunk/dabo/ui/uiwx/dRadioList.py 2007-03-19 18:16:34 UTC (rev 2934)
+++ trunk/dabo/ui/uiwx/dRadioList.py 2007-03-19 19:47:01 UTC (rev 2935)
@@ -172,7 +172,6 @@
# This allows the event processing to properly
# set the EventData["index"] properly.
evt.SetInt(pos)
- self.flushValue()
self.super(evt)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev