/GUI/Generic/MenuLists.py

https://bitbucket.org/alsh/pygui-mirror · Python · 24 lines · 12 code · 3 blank · 9 comment · 4 complexity · a17c24a2101d0687baa807c774b169fa MD5 · raw file

  1. #
  2. # Python GUI - Menu Lists - Generic
  3. #
  4. class MenuList(list):
  5. """A MenuList is a sequence of Menus with methods for finding
  6. menus and menu items by command."""
  7. def menu_with_command(self, cmd):
  8. """Returns the menu containing the given command, or None
  9. if there is no such menu in the list."""
  10. for menu in self:
  11. if menu.item_with_command(cmd):
  12. return menu
  13. return None
  14. def item_with_command(self, cmd):
  15. """Returns the menu item having the given command, or None
  16. if there is no such item."""
  17. for menu in self:
  18. item = menu.item_with_command(cmd)
  19. if item:
  20. return item
  21. return None