[PythonReports-checkins] PythonReports/PythonReports design.py, 1.1, 1.2
Brought to you by:
a1s
From: alexander s. <a1...@us...> - 2006-11-02 18:42:27
|
Update of /cvsroot/pythonreports/PythonReports/PythonReports In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21366 Modified Files: design.py Log Message: pop up menus on right-click and insert key in the list Index: design.py =================================================================== RCS file: /cvsroot/pythonreports/PythonReports/PythonReports/design.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** design.py 1 Nov 2006 11:07:02 -0000 1.1 --- design.py 2 Nov 2006 18:42:21 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- """PythonReports Template Designer""" + """History (most recent first): + 02-nov-2006 [als] pop up menus on right-click and insert key in the list 31-oct-2006 [als] boolean property checkbuttons have grey background; fix: ElementTree not updated on element deletion; *************** *** 700,703 **** --- 702,707 ---- _tree_hlist.bind("<Delete>", lambda event: self.deleteNode(self.current_node)) + _tree_hlist.bind("<Insert>", self.OnTreeInsert) + _tree_hlist.bind("<Button-3>", self.OnTreeRClick) self.hp.add(self.tree) # Tkish way to get standard visual attributes is .option_get(), *************** *** 885,888 **** --- 889,928 ---- state=(NORMAL, DISABLED)[_data.tag in self.FIXED_TAGS]) + def _get_popup_position(self): + """Return position for the tree popup menu + + Menu is popped up with it's top left corner just below + currently selected tree node, offset from the left side + by the nesting level. + + Return value: 2-element tuple (x, y). + + """ + _hlist = self.tree.hlist + _bbox = _hlist.tk.call(str(_hlist), "info", "bbox", self.current_node) + _ypos = _hlist.winfo_rooty() + int(_bbox.split(" ")[3]) + _xpos = _hlist.winfo_rootx() + 20 * (self.current_node.count(".") + 1) + return (_xpos, _ypos) + + def OnTreeRClick(self, event): + """Right click on the tree list - open pulldown menu""" + # set focus to the tree: click moves selection pointer + # and it looks like the pointer can further be moved + # by keyboard. not true unless we force focus to the tree. + _hlist = self.tree.hlist + _hlist.focus_set() + # select tree node nearest to the click position + _path = _hlist.nearest(event.y) + self.select(_path) + # menu will be popped up below selected row, + # horizontally near to the click position + self.report_menu.tk_popup(event.x_root, self._get_popup_position()[1]) + + def OnTreeInsert(self, event): + """Insert key pressed in the tree - pop up insert element menu""" + _menu = self.insert_menus[self.getNodeData(self.current_node).tag] + if _menu: + _menu.tk_popup(*self._get_popup_position()) + def OnPropListResize(self, event=0): """Adjust width of value col in the property list upon window resize""" |