dabo Commit
Revision 4278
Date: 2008-07-13 16:49:48 -0700 (Sun, 13 Jul 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4278

Changed:
U   trunk/dabo/lib/propertyHelperMixin.py
U   trunk/dabo/ui/uiwx/__init__.py

Log:
Added the ability to specify additional properties, such as Dynamic*, in an 
.mnxml file.

Updated propertyHelperMixin to accommodate an optional context parameter for 
evaluating attProperty strings.


Diff:
Modified: trunk/dabo/lib/propertyHelperMixin.py
===================================================================
--- trunk/dabo/lib/propertyHelperMixin.py       2008-07-13 22:30:01 UTC (rev 
4277)
+++ trunk/dabo/lib/propertyHelperMixin.py       2008-07-13 23:49:48 UTC (rev 
4278)
@@ -213,13 +213,14 @@
                _setProps(propKw)
 
                        
-       def setPropertiesFromAtts(self, propDict={}, ignoreExtra=True):
+       def setPropertiesFromAtts(self, propDict={}, ignoreExtra=True, 
context=None):
                """ Sets a group of properties on the object all at once. This
                is different from the regular setProperties() method because
                it only accepts a dict containing prop:value pairs, and it
                assumes that the value is always a string. It will convert
                the value to the correct type for the property, and then set
-               the property to that converted value.
+               the property to that converted value. If the value needs to be 
evaluated 
+               in a specific namespace, pass that as the 'context' parameter.
                """
                for prop, val in propDict.items():
                        if not hasattr(self, prop):
@@ -229,7 +230,11 @@
                                        continue
                                else:
                                        raise AttributeError, "'%s' is not a 
property." % prop
-                       setattr(self, prop, val)
+                       try:
+                               valToSet = eval(val, context)
+                       except NameError:
+                               valToSet = val
+                       setattr(self, prop, valToSet)
                
        
        def _setKwEventBindings(self, kwEvtDict):

Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py      2008-07-13 22:30:01 UTC (rev 4277)
+++ trunk/dabo/ui/uiwx/__init__.py      2008-07-13 23:49:48 UTC (rev 4278)
@@ -1160,23 +1160,23 @@
                                menu.appendSeparator()
                        else:
                                itmatts = itm["attributes"]
-                               cap = itmatts["Caption"]
-                               hk = itmatts["HotKey"]
-                               pic = itmatts["Picture"]
-                               special = itmatts.get("special", None)
+                               cap = menu._extractKey(itmatts, "Caption")
+                               hk = menu._extractKey(itmatts, "HotKey")
+                               pic = menu._extractKey(itmatts, "Picture")
+                               special = menu._extractKey(itmatts, "special", 
None)
                                binding = previewFunc
-                               fnc = ""
-                               useFunc = ("Action" in itmatts) and 
(itmatts["Action"])
-                               if useFunc:
-                                       fnc = itmatts["Action"]
+                               fnc = menu._extractKey(itmatts, "Action", "")
                                if (binding is None) and fnc:
                                        try:
                                                binding = eval(fnc)
                                        except NameError:
                                                binding = fnc
-                               help = itmatts["HelpText"]
+                               help = menu._extractKey(itmatts, "HelpText")
                                menuItem = menu.append(cap, OnHit=binding, 
help=help,
                                                picture=pic, special=special, 
HotKey=hk)
+                               if itmatts:
+                                       menuItem.setPropertiesFromAtts(itmatts, 
+                                                       context={"form": form, 
"app": dabo.dAppRef})
 
        try:
                srcFile = resolvePathAndUpdate(srcFile)




_______________________________________________
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