[PythonReports-checkins] PythonReports/PythonReports design.py, 1.13, 1.14
Brought to you by:
a1s
From: alexander s. <a1...@us...> - 2006-12-06 19:27:03
|
Update of /cvsroot/pythonreports/PythonReports/PythonReports In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30189 Modified Files: design.py Log Message: rebuild insertion menu each time selected node tag changes: prebuilt menu reuse didn't work reliably Index: design.py =================================================================== RCS file: /cvsroot/pythonreports/PythonReports/PythonReports/design.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** design.py 6 Dec 2006 18:24:52 -0000 1.13 --- design.py 6 Dec 2006 19:26:57 -0000 1.14 *************** *** 5,8 **** --- 5,10 ---- """PythonReports Template Designer""" """History (most recent first): + 06-dec-2006 [als] rebuild insertion menu each time selected node tag changes: + prebuilt menu reuse didn't work reliably 06-dec-2006 [als] fix: box attributes not updated 05-dec-2006 [als] fix errors and some warnings reported by pylint *************** *** 964,974 **** if _tag in self.insert_menus: return ! # return early if validator has no children (no insert menu) if not validator.children: - self.insert_menus[_tag] = None return # create submenu for "insert element" cascade - _menu = Menu(self.report_menu, tearoff=False) - self.insert_menus[_tag] = _menu _hotkeys = set() for (_child, _restrict) in validator.children: --- 966,974 ---- if _tag in self.insert_menus: return ! _menu = self.insert_menus[_tag] = [] ! # return early if validator has no children (insert menu empty/unused) if not validator.children: return # create submenu for "insert element" cascade _hotkeys = set() for (_child, _restrict) in validator.children: *************** *** 989,994 **** # if the loop is empty, the variable is initialized # in the else clause. ! self._build_menu_item(_menu, _child.tag, underline=_underline, ! command=lambda tag=_child.tag: self.insertNode(tag)) @staticmethod --- 989,994 ---- # if the loop is empty, the variable is initialized # in the else clause. ! _menu.append(dict(label=_child.tag, underline=_underline, ! command=lambda tag=_child.tag: self.insertNode(tag))) @staticmethod *************** *** 1148,1163 **** if (node == self.current_node) and not force: return # TODO? if self.current_node is not None, # update from the properties list _data = self.getNodeData(node) _data.loadPropertyList(self.pl.hlist) self.current_node = node - # replace insertion menu - _rmenu = self.report_menu - _imenu = self.insert_menus[_data.tag] - if _imenu is None: - _rmenu.entryconfigure(0, state=DISABLED) - else: - _rmenu.entryconfigure(0, state=NORMAL, menu=_imenu) # enable/disable other element commands _rmenu.entryconfigure(1, --- 1148,1174 ---- if (node == self.current_node) and not force: return + # spare some keystrokes and attribute lookups + _rmenu = self.report_menu # TODO? if self.current_node is not None, # update from the properties list _data = self.getNodeData(node) _data.loadPropertyList(self.pl.hlist) + if (not self.current_node) \ + or (_data.tag != self.getNodeData(self.current_node).tag): + # element type changed - replace insertion menu + # destroy current menu, if any + _imenu = _rmenu.entrycget(0, "menu") + if _imenu: + _imenu = _rmenu.nametowidget(_imenu) + _rmenu.entryconfigure(0, state=DISABLED, menu="") + _imenu.destroy() + # build new insertion menu, if any + _imenu_def = self.insert_menus[_data.tag] + if _imenu_def: + _imenu = Menu(_rmenu, tearoff=False) + for _args in _imenu_def: + self._build_menu_item(_imenu, **_args) + _rmenu.entryconfigure(0, state=NORMAL, menu=_imenu) self.current_node = node # enable/disable other element commands _rmenu.entryconfigure(1, |