dabo Commit
Revision 4420
Date: 2008-08-18 10:39:41 -0700 (Mon, 18 Aug 2008)
Author: Paul
Trac: http://svn.dabodev.com/trac/dabo/changeset/4420
Changed:
U trunk/dabo/ui/uiwx/dControlItemMixin.py
Log:
Fixed up the setting of KeyValue in dControlItemMixin, so that if KeyValue
is getting set to a non-existent key, the control will have nothing selected
and the Value will be None. This I believe was the intent all along but
visually, at least dDropdownList wasn't doing it, and confusing infoLog
messages were being generated.
Tested with dDropdownList on Linux.
Diff:
Modified: trunk/dabo/ui/uiwx/dControlItemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dControlItemMixin.py 2008-08-17 00:17:01 UTC (rev
4419)
+++ trunk/dabo/ui/uiwx/dControlItemMixin.py 2008-08-18 17:39:41 UTC (rev
4420)
@@ -202,29 +202,29 @@
# Clear all current selections:
self.clearSelections()
- # Check what type of key collection we are using: dict
or list
- keysAreDict = isinstance(self.Keys, dict)
+ validSelections = []
# Select items that match indices in value:
for key in value:
- if keysAreDict:
- if not self.Keys.has_key(key):
- # If the appdev set up a key
for None, use it.
- key = None
+ if isinstance(self.Keys, dict):
try:
-
self.setSelection(self.Keys[key])
+
validSelections.append(self.Keys[key])
except KeyError:
- # The specified key isn't
found, and there's no None key. We
- # can't cope but wxPython can
set a blank value:
- self._setSelection(-1)
-
+ pass
else:
- # we are using a tuple/list of keys.
Find its position
try:
-
self.setSelection(self.Keys.index(key))
+
validSelections.append(self.Keys.index(key))
except ValueError:
- # No such key; write an info
message, but otherwise ignore it.
- dabo.infoLog.write(_("Key '%s'
not found") % key)
- continue
+ pass
+
+ if validSelections:
+ self.setSelection(validSelections)
+ else:
+ # No valid selections: tell wxPython not to
select anything:
+ self._setSelection(-1)
+ chc = self.Choices
+ self.Choices = []
+ self.Choices = chc
+
self._afterValueChanged()
else:
self._properties["KeyValue"] = value
_______________________________________________
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]