[PythonReports-checkins] PythonReports/PythonReports design.py, 1.3, 1.4
Brought to you by:
a1s
From: alexander s. <a1...@us...> - 2006-11-03 11:29:29
|
Update of /cvsroot/pythonreports/PythonReports/PythonReports In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28383 Modified Files: design.py Log Message: pop up the tree menu on Shift+F10; added element reordering commands "move up" and "move down" Index: design.py =================================================================== RCS file: /cvsroot/pythonreports/PythonReports/PythonReports/design.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** design.py 2 Nov 2006 19:55:38 -0000 1.3 --- design.py 3 Nov 2006 11:29:24 -0000 1.4 *************** *** 2,5 **** --- 2,7 ---- """History (most recent first): + 02-nov-2006 [als] pop up the tree menu on Shift+F10; + added element reordering commands "move up" and "move down" 02-nov-2006 [als] create automatic hotkeys in insertion menus 02-nov-2006 [als] pop up menus on right-click and insert key in the list *************** *** 705,708 **** --- 707,712 ---- _tree_hlist.bind("<Insert>", self.OnTreeInsert) _tree_hlist.bind("<Button-3>", self.OnTreeRClick) + _tree_hlist.bind("<Shift-F10>", lambda event: + self.report_menu.tk_popup(*self._get_popup_position())) self.hp.add(self.tree) # Tkish way to get standard visual attributes is .option_get(), *************** *** 762,765 **** --- 766,772 ---- self._build_menu_item(_popup, ''"_Delete element", command=lambda: self.deleteNode(self.current_node)) + self._build_menu_item(_popup, ''"Move _Up", command=self.OnMenuMoveUp) + self._build_menu_item(_popup, ''"Move Dow_n", + command=self.OnMenuMoveDown) _popup.add_separator() self._build_menu_item(_popup, ''"Print Pre_view", command=self.preview) *************** *** 879,886 **** """Display "About..." dialog""" ! def OnTreeBrowse(self, node): """Select new item on the tree""" # XXX why the browse event always comes twice? ! if node == self.current_node: return # TODO? if self.current_node is not None, --- 886,942 ---- """Display "About..." dialog""" ! def OnMenuMoveUp(self): ! """Move selected node before it's previous sibling""" ! _path = self.current_node ! _data = self.getNodeData(_path) ! _parent = _data.parent ! if not _parent: ! # can't happen - menu item should be disabled ! return ! _idx = _parent.index(_data) ! if _idx < 1: ! # can't happen either ! return ! _sibling = _parent[_idx - 1] ! _parent[_idx-1:_idx+1] = (_data, _sibling) ! self.tree.hlist.delete_entry(_path) ! _data.addToTree(self.tree, before=_sibling.path) ! self.tree.autosetmode() ! self.select(_path) ! ! def OnMenuMoveDown(self): ! """Move selected node after it's next sibling""" ! _path = self.current_node ! _data = self.getNodeData(_path) ! _parent = _data.parent ! if not _parent: ! # can't happen - menu item should be disabled ! return ! _idx = _parent.index(_data) ! if (_idx + 1) >= len(_parent): ! # can't happen either ! return ! _parent[_idx:_idx+2] = (_parent[_idx+1], _data) ! self.tree.hlist.delete_entry(_path) ! try: ! _before = _parent[_idx+2] ! except IndexError: ! # at the end of the siblings list ! _before = None ! else: ! _before = _before.path ! _data.addToTree(self.tree, before=_before) ! self.tree.autosetmode() ! self.select(_path) ! ! @staticmethod ! def _enabled(enable): ! """Return Tk widget state constant for boolean value""" ! return (DISABLED, NORMAL)[bool(enable)] ! ! def OnTreeBrowse(self, node, force=False): """Select new item on the tree""" # XXX why the browse event always comes twice? ! if (node == self.current_node) and not force: return # TODO? if self.current_node is not None, *************** *** 890,901 **** self.current_node = node # replace insertion menu ! _menu = self.insert_menus[_data.tag] ! if _menu is None: ! self.report_menu.entryconfigure(0, state=DISABLED) else: ! self.report_menu.entryconfigure(0, state=NORMAL, menu=_menu) ! # enable/disable "Delete element" command ! self.report_menu.entryconfigure(1, ! state=(NORMAL, DISABLED)[_data.tag in self.FIXED_TAGS]) def _get_popup_position(self): --- 946,966 ---- 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, ! state=self._enabled(_data.tag not in self.FIXED_TAGS)) ! if _data.parent is None: ! _rmenu.entryconfigure(2, state=DISABLED) ! _rmenu.entryconfigure(3, state=DISABLED) ! else: ! _index = _data.parent.index(_data) ! _rmenu.entryconfigure(2, state=self._enabled(_index > 0)) ! _rmenu.entryconfigure(3, ! state=self._enabled((_index + 1) < len(_data.parent))) def _get_popup_position(self): *************** *** 980,984 **** _hlist.selection_set(path) _hlist.anchor_set(path) ! self.OnTreeBrowse(path) def getNodeData(self, path): --- 1045,1049 ---- _hlist.selection_set(path) _hlist.anchor_set(path) ! self.OnTreeBrowse(path, force=True) def getNodeData(self, path): |