According to the Tix documentation online, HList has an info_bbox() method which returns the bounding box of a given item in the HList. However, when I try to call this method, I get an attribute error. Looking at Tix.py I see that info_bbox() is not implemented. Hazarding a chance (mostly by looking at the other method implementation) I see if I can define it myself. def info_bbox( self, entry ): return [ int(pos) for pos in self.tk.call( self._w, 'info', 'bbox', entry).split() ] When I use this implementation it works. Why's info_bbox() been left out of HList? I can't formulate a work-around for what I'm trying to do. I need info_bbox(). Here's why: I'm currently working on a project which involves some fairly complex GUIs. It displays data in the form of an outline which the user can edit, it also generates web pages. To allow a natural feel to editing the order of the items in the outline, I decided to make use of the Tkinter drag and drop module: Tkdnd. To do this correctly, I need to do a bit of arithmetic with screen coordinates while in a drag operation (so I can change the cursor during the drag) so that I can determine if my current drag position (potential drop position) is above, below or as a child of some other item in the outline. The easiest way to do this is to get the bounding box of the nearest items. Thanks, Ron
On Wed, 29 Aug 2007 15:54:46 -0400 "Ron Provost" <ronpro@cox.net> wrote:
According to the Tix documentation online, HList has an info_bbox() method which returns the bounding box of a given item in the HList. However, when I try to call this method, I get an attribute error. Looking at Tix.py I see that info_bbox() is not implemented.
Hazarding a chance (mostly by looking at the other method implementation) I see if I can define it myself.
def info_bbox( self, entry ): return [ int(pos) for pos in self.tk.call( self._w, 'info', 'bbox', entry).split() ]
When I use this implementation it works. Why's info_bbox() been left out of HList?
Hi Ron, this is not much of a surprise to me, there are more things missing from the Tix module. Probably it is the best to use your "private" Tix module with the added info_bbox() method. If you like you can send a patch to the python developers to fix this. BTW, maybe there is a bug in your implementation of info_bbox(), it will fail if the tcl method returns an empty string which might happen if the named item does not exist or so. You better use self._getints() as in Tkinter.Canvas.bbox() : def info_bbox( self, entry ): return self._getints(self.tk.call(self._w, ´info´, 'bbox', entry)) or None I hope this helps Michael
participants (2)
-
Michael Lange -
Ron Provost