changeset 79:33677d99ebdf

addMenu allows to add a new category without adding an item
author souliane <souliane@mailoo.org>
date Mon, 07 Apr 2014 19:58:13 +0200
parents 56c02f4731f9
children 2d66ac0f4d75
files urwid_satext/sat_widgets.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/urwid_satext/sat_widgets.py	Tue Apr 01 20:58:12 2014 +0200
+++ b/urwid_satext/sat_widgets.py	Mon Apr 07 19:58:13 2014 +0200
@@ -760,8 +760,9 @@
                 callback((category, item))
         return key
 
-    def addMenu(self, category, item, callback, shortcut=None):
-        """Add a menu item, create the category if new
+    def addMenu(self, category, item=None, callback=None, shortcut=None):
+        """Create the category if new and add a menu item (if item is not None).
+
         @param category: category of the menu (e.g. File/Edit)
         @param item: menu item (e.g. new/close/about)
         @callback: method to call when item is selected"""
@@ -772,6 +773,8 @@
                                    left_border = ('menubar',"[ "),
                                    right_border = ('menubar'," ]"))
             self._w.base_widget.addWidget(button,button.getSize())
+        if not item:
+            return
         self.menu[category].append((item, callback))
         if shortcut:
             assert(shortcut not in self.shortcuts.keys())