[Tkinter-discuss] Find_closest, bbox, and weirdness
Russell E Owen
rowen at cesmail.net
Thu Jan 18 21:36:18 CET 2007
In article <45AF2253.2080903 at juno.com>, Jeff Cagle <jrcagle at juno.com>
> So I was trying to pretty up a GUI. It took 20 minutes to write code to
> place names in a circle and draw arrows to the names that are related
> (actually, the names are filenames, and the arrows represent 'import' or
> 'from ... import' statements).
> It's taken a couple of hours to try to clean it up so that the arrows go
> up to the bounding box of the text, but not inside.
> Here was the plan: Compute the line that connects the centers of the
> text objects. Figure out where that line intersects the bounding boxes
> of the texts, and draw the lines to the intersection points instead of
> It all works ... except that I don't get the right bounding boxes.
> Here's the code:
it sounds like object with ID 1 may be overlapping all the other
objects. Tk's find_closest is primitive in how it handles overlap.
Unless you can guarantee that your text objects will never overlap I
suggest you find the closest one yourself. Keep a list of object coords
and scan through them. If the objects can be moved around then use a
callback to update the position.
More information about the Tkinter-discuss