/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/menu.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/menu.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 236 by bh, Tue Jul 23 16:53:14 2002 UTC revision 1061 by jan, Tue May 27 13:11:18 2003 UTC
# Line 9  Line 9 
9    
10  __version__ = "$Revision$"  __version__ = "$Revision$"
11    
12    from Thuban import _
13    
14  class Menu:  class Menu:
15    
# Line 41  class Menu: Line 42  class Menu:
42      def item_index(self, item):      def item_index(self, item):
43          """Return the index of item in the menu.          """Return the index of item in the menu.
44    
45          The item parameter may be the name of a non-menu entry or the          item -- may be the name of a non-menu entry or the
46          name of a menu or a menu itself.                  name of a menu or a menu itself.
47    
48          Return None it item is not found.          Return None it item is not found.
49          """          """
# Line 86  class Menu: Line 87  class Menu:
87                  submenu_index.InsertItem(item, menu = menu[1:], after = after)                  submenu_index.InsertItem(item, menu = menu[1:], after = after)
88              else:              else:
89                  # the submenu doesn't exist yet. Raise an error.                  # the submenu doesn't exist yet. Raise an error.
90                  raise KeyError("Submenu %s doesn't exist" % menu[0])                  raise KeyError(_("Submenu %s doesn't exist") % menu[0])
91          else:          else:
92              if after is not None:              if after is not None:
93                  idx = self.item_index(after)                  idx = self.item_index(after)
# Line 98  class Menu: Line 99  class Menu:
99              else:              else:
100                  self.items.append(item)                  self.items.append(item)
101    
102      def InsertSeparator(self):      def InsertSeparator(self, after = None):
103          """Insert a separator"""          """Insert a separator
104          self.InsertItem(None)  
105            after -- (optional) insert the separator after this one. after
106                     should be the name of a command.
107            """
108            self.InsertItem(None, after = after)
109    
110      def InsertMenu(self, name, title, menu = (), after = None):      def InsertMenu(self, name, title, menu = (), after = None):
111          """Insert and return a new menu.          """Insert and return a new menu.
# Line 124  class Menu: Line 129  class Menu:
129      def SetItems(self, items):      def SetItems(self, items):
130          """Replace the contents of the menu by items."""          """Replace the contents of the menu by items."""
131          self.items = items          self.items = items
132    
133        def RemoveItem(self, item):
134            """Remove an item from the menu.
135    
136            item -- the (internal) name of the item.
137            """
138            i = self.item_index(item)
139            if i is not None:
140                self.items.pop(i)

Legend:
Removed from v.236  
changed lines
  Added in v.1061

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26