Changeset 4278
- Timestamp:
- 07/13/08 16:49:48 (1 month ago)
- Files:
-
- trunk/dabo/lib/propertyHelperMixin.py (modified) (3 diffs)
- trunk/dabo/ui/uiwx/__init__.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/lib/propertyHelperMixin.py
r4238 r4278 214 214 215 215 216 def setPropertiesFromAtts(self, propDict={}, ignoreExtra=True ):216 def setPropertiesFromAtts(self, propDict={}, ignoreExtra=True, context=None): 217 217 """ Sets a group of properties on the object all at once. This 218 218 is different from the regular setProperties() method because … … 220 220 assumes that the value is always a string. It will convert 221 221 the value to the correct type for the property, and then set 222 the property to that converted value. 222 the property to that converted value. If the value needs to be evaluated 223 in a specific namespace, pass that as the 'context' parameter. 223 224 """ 224 225 for prop, val in propDict.items(): … … 230 231 else: 231 232 raise AttributeError, "'%s' is not a property." % prop 232 setattr(self, prop, val) 233 try: 234 valToSet = eval(val, context) 235 except NameError: 236 valToSet = val 237 setattr(self, prop, valToSet) 233 238 234 239 trunk/dabo/ui/uiwx/__init__.py
r4265 r4278 1161 1161 else: 1162 1162 itmatts = itm["attributes"] 1163 cap = itmatts["Caption"]1164 hk = itmatts["HotKey"]1165 pic = itmatts["Picture"]1166 special = itmatts.get("special", None)1163 cap = menu._extractKey(itmatts, "Caption") 1164 hk = menu._extractKey(itmatts, "HotKey") 1165 pic = menu._extractKey(itmatts, "Picture") 1166 special = menu._extractKey(itmatts, "special", None) 1167 1167 binding = previewFunc 1168 fnc = "" 1169 useFunc = ("Action" in itmatts) and (itmatts["Action"]) 1170 if useFunc: 1171 fnc = itmatts["Action"] 1168 fnc = menu._extractKey(itmatts, "Action", "") 1172 1169 if (binding is None) and fnc: 1173 1170 try: … … 1175 1172 except NameError: 1176 1173 binding = fnc 1177 help = itmatts["HelpText"]1174 help = menu._extractKey(itmatts, "HelpText") 1178 1175 menuItem = menu.append(cap, OnHit=binding, help=help, 1179 1176 picture=pic, special=special, HotKey=hk) 1177 if itmatts: 1178 menuItem.setPropertiesFromAtts(itmatts, 1179 context={"form": form, "app": dabo.dAppRef}) 1180 1180 1181 1181 try:
