Changeset 3526

Show
Ignore:
Timestamp:
10/19/2007 06:09:38 PM (10 months ago)
Author:
ed
Message:

This reverts some of my previous changes, as the docs for wx.Menu don't appear to be correct under Gtk.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/ui/uiwx/dMenu.py

    r3521 r3526  
    1010import dabo.dEvents as dEvents 
    1111from dabo.ui import makeDynamicProperty 
     12from dabo.lib.utils import cleanMenuCaption 
    1213 
    1314# wx constants for styles 
     
    392393 
    393394 
     395    def _itemByCaption(self, cap, returnPos=False): 
     396        """Common method for locating a menu item by its caption, ignoring 
     397        all the 'special' characters for acceleration. 
     398        """ 
     399        cap = cleanMenuCaption(cap, "&_") 
     400        for pos in xrange(self.GetMenuItemCount()): 
     401            itm = self.FindItemByPosition(pos) 
     402            itmCap = cleanMenuCaption(itm.GetLabel(), "&_") 
     403            if itmCap == cap: 
     404                if returnPos: 
     405                    return pos 
     406                else: 
     407                    return self._daboChildren.get(itm.GetId(), None) 
     408        return None 
     409 
     410 
    394411    def getItemIndex(self, caption): 
    395         """Returns the index of the item with the specified caption. 
    396  
    397         If the item isn't found, None is returned. 
    398         """ 
    399         wxItem = self.FindItem(caption) 
    400         for pos in xrange(self.GetMenuItemCount()): 
    401             fip = self.FindItemByPosition(pos).GetId() 
    402             if self.FindItemByPosition(pos).GetId() == wxItem: 
    403                 return pos 
    404         return None 
     412        """Returns the index of the item with the specified caption. If the item 
     413        isn't found, None is returned. 
     414        """ 
     415        return self._itemByCaption(caption, True) 
    405416         
    406417 
    407418    def getItem(self, caption): 
    408         """Returns a reference to the menu item with the specified caption. 
    409  
    410         If the item isn't found, None is returned. 
    411         """ 
    412         return self._daboChildren.get(self.FindItem(caption), None) 
     419        """Returns a reference to the menu item with the specified caption. If the item 
     420        isn't found, None is returned. 
     421        """ 
     422        return self._itemByCaption(caption) 
    413423 
    414424