def __init__(self,type='menu'): if type=='menu':m = winuser.CreateMenu() else: m=winuser.CreatePopupMenu() self.__dict__['_obj_'] = m self._dynamic_cascade_dict={} # dict holding dynamic menus, valid until next call self._toggles={} self._optional_flags = flags.curflags()
def __init__(self, menubartemplate): import settings import features self.curflags = flags.curflags() self.cmd_to_menu = {} self.cmd_enabled = {} ## self.must_update_window_menu = 1 ## self.must_update_document_menu = 1 self.all_cmd_groups = [None, None, None] self.menubartraversal = [] for menutemplate in menubartemplate: flag, entrytype, title, content = menutemplate if flag & self.curflags: menu = mw_globals.toplevel._addmenu(title) rv = self.fillmenu(menu, entrytype, content) self.menubartraversal.append(rv)
def _fill_menu(self, menu, list, callbackfunc): curflags = flags.curflags() for item in list: flag = item[0] if not (flag & curflags): continue if item[1] == MenuTemplate.SEP: menu.addseparator() elif item[1] == MenuTemplate.ENTRY: itemstring = item[2] cmd = item[4] callback = (callbackfunc, (cmd, )) m = MenuItem(menu, itemstring, '', callback) self._cmd_to_item[cmd] = m m.enable(0) #DBG elif item[1] == MenuTemplate.CASCADE: itemstring = item[2] list = item[3] m = menu.addsubmenu(itemstring) self._themenu.adddependent(m) self._fill_menu(m, list, callbackfunc) else: raise 'Only SEP, ENTRY or CASCADE in popup', list