def add(self, label, function, menu=None): item = RadioMenuItem(label=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 __init__(self, commands, function, menu=None): SimpleMenu.__init__(self) self.main_item = RadioMenuItem(label=commands[0]) self._menu_dict[commands[0]] = self.main_item for command in commands[1:]: item = RadioMenuItem(self.main_item, label=command) item.set_name(command) self.append(item) if menu: item.connect('activate', function, command, menu) else: item.connect('activate', function, command) item.show() self._menu_dict[command] = item