[Tkinter-discuss] Find_closest, bbox, and weirdness
Russell E Owen
rowen at cesmail.net
Thu Jan 18 22:30:47 CET 2007
At 9:21 PM +0000 2007-01-18, Cameron Laird wrote:
>On Thu, Jan 18, 2007 at 12:36:18PM -0800, Russell E Owen wrote:
>> > 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
>> > center-to-center.
>> > 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.
>? I've had *great* results with "closest". While I agree
>that your approach should be kept in mind, it's not the
>first one I try when I'm in the situation I understand from
>the original description. Do you have any details on how
>"closest" has failed for you?
My problem was find_closest's handling of overlapping objects. I
built a star display (stars on an Az/Alt grid). I wanted data for the
star closest to the pointer displayed. But sometimes the blobs
representing stars overlap causing data for the wrong star to be
I suppose I could have added an invisible single pixel object at the
center of each visible blob and found using that. But I'm happier
with my solution.
More information about the Tkinter-discuss