dabo Commit
Revision 3947
Date: 2008-03-08 09:35:13 -0800 (Sat, 08 Mar 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/3947
Changed:
U trunk/dabo/ui/uiwx/__init__.py
U trunk/dabo/ui/uiwx/dMenuItem.py
U trunk/dabo/ui/uiwx/dPemMixin.py
Log:
Added the '_delayedEventBindings' attribute to dPemMixin. This was needed for
menus created by MenuDesigner mnxml files for Actions that involve the form.
Turns out that the menu's OnHit is processed before the reference to
'self.Form' has been set, so it was impossible to set a menu item's action to
something like 'self.Form.menuHandler()'. These changes simply delay the
binding until after the menu item has been fully created, allowing the
framework to properly resolve the binding.
Diff:
Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py 2008-03-06 23:37:32 UTC (rev 3946)
+++ trunk/dabo/ui/uiwx/__init__.py 2008-03-08 17:35:13 UTC (rev 3947)
@@ -1116,7 +1116,10 @@
if useFunc:
fnc = itmatts["Action"]
if (binding is None) and fnc:
- binding = eval(fnc)
+ try:
+ binding = eval(fnc)
+ except NameError:
+ binding = fnc
help = itmatts["HelpText"]
menuItem = menu.append(cap, OnHit=binding,
help=help,
picture=pic)
@@ -1248,7 +1251,7 @@
def saveScreenShot(obj=None, imgType=None, pth=None, delaySeconds=None):
- """Takes a screenshot of the specified and writes it to a file,
converting
+ """Takes a screenshot of the specified object and writes it to a file,
converting
it to the requested image type. If no object is specified, the current
ActiveForm is used. You can add an optional delaySeconds setting that
will let you set things up as needed before the image is taken; if not
specified,
Modified: trunk/dabo/ui/uiwx/dMenuItem.py
===================================================================
--- trunk/dabo/ui/uiwx/dMenuItem.py 2008-03-06 23:37:32 UTC (rev 3946)
+++ trunk/dabo/ui/uiwx/dMenuItem.py 2008-03-08 17:35:13 UTC (rev 3947)
@@ -33,7 +33,7 @@
## wx.MenuItems don't have a Bind() of their own, so this
serves to
## override the base behavior in dPemMixin._initEvents() which
has
## a bunch of wx Events that don't exist for menu items (IOW,
don't
- ## call doDefault!).
+ ## call the superclass method!).
if self.Application is not None:
# Set up a mechanism to catch menu selected events
@@ -42,6 +42,9 @@
self.Application.uiApp.Bind(wx.EVT_MENU,
self.__onWxHit, self)
self.Application.uiApp.Bind(wx.EVT_MENU_HIGHLIGHT,
self.__onWxMenuHighlight, self)
+ # Handle delayed event bindings
+ if self._delayedEventBindings:
+ dabo.ui.callAfter(self._bindDelayed)
def __onWxMenuHighlight(self, evt):
Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py 2008-03-06 23:37:32 UTC (rev 3946)
+++ trunk/dabo/ui/uiwx/dPemMixin.py 2008-03-08 17:35:13 UTC (rev 3947)
@@ -34,6 +34,9 @@
self._properties = {}
# Holds the keyword event bindings passed in the constructor
self._kwEvents = {}
+ # Holds event binding expressed as strings to be eval'd after
this object
+ # has been constructed.
+ self._delayedEventBindings = []
# There are a few controls that don't yet support 3-way inits
(grid, for
# one). These controls will send the wx classref as the
preClass argument,
@@ -421,8 +424,22 @@
pass
self.initEvents()
+
+ # Handle delayed event bindings
+ if self._delayedEventBindings:
+ dabo.ui.callAfter(self._bindDelayed)
+ def _bindDelayed(self):
+ for evt, mthdString in self._delayedEventBindings:
+ try:
+ mthd = eval(mthdString)
+ except (AttributeError, NameError), e:
+ dabo.errorLog.write(_("Could not evaluate
method '%s': %s") % (mthdString, e))
+ continue
+ self.bindEvent(evt, mthd)
+
+
def __onMouseEnter(self, evt):
if self._hover:
if self._hoverTimer is None:
_______________________________________________
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]