def populate_menu(mainmenu, section, commands, function): new_menu = SimpleMenu() section_item = MenuItem(section) section_item.set_name(section) section_item.show() section_item.set_submenu(new_menu) mainmenu.append(section_item) for command in commands: new_menu.add(command, function, section_item)
def add(self, label, function, menu=None): item = MenuItem(label) item.set_name(label) self.append(item) if menu: item.connect('activate', function, label, menu) else: item.connect('activate', function, label) item.show() self._menu_dict[label] = item
def append(self, menu, name): item = MenuItem(name) item.show() item.set_submenu(menu) MenuBar.append(self, item) self._menu_dict[name] = menu