dabo Commit
Revision 6202
Date: 2010-11-22 18:49:34 -0800 (Mon, 22 Nov 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6202
Changed:
U trunk/dabo/ui/uiwx/dMenu.py
Log:
Modified the getItemIndex() method to take either a caption (existing
behavior), or an actual menu item.
Diff:
Modified: trunk/dabo/ui/uiwx/dMenu.py
===================================================================
--- trunk/dabo/ui/uiwx/dMenu.py 2010-11-22 16:33:03 UTC (rev 6201)
+++ trunk/dabo/ui/uiwx/dMenu.py 2010-11-23 02:49:34 UTC (rev 6202)
@@ -422,7 +422,9 @@
def _itemByCaption(self, cap, returnPos=False):
"""Common method for locating a menu item by its caption,
ignoring
- all the 'special' characters for acceleration.
+ all the 'special' characters for acceleration. If 'returnPos' is
+ True, the position of the found item is returned instead of the
+ item itself.
"""
cap = cleanMenuCaption(cap, "&_")
for pos in xrange(self.GetMenuItemCount()):
@@ -436,11 +438,16 @@
return None
- def getItemIndex(self, caption):
- """Returns the index of the item with the specified caption. If
the item
+ def getItemIndex(self, captionOrItem):
+ """Returns the index of the item with the specified caption;
you can
+ optionally pass in a reference to the menu item itself. If the
item
isn't found, None is returned.
"""
- return self._itemByCaption(caption, True)
+ try:
+ return self.Children.index(captionOrItem)
+ except ValueError:
+ # Not a menu item
+ return self._itemByCaption(captionOrItem, True)
def getItem(self, idOrCaption):
_______________________________________________
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]