| | 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 | |
|---|
| 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) |
|---|