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