Canvas - Rectangle. Is there an easy way to detect if you're inside?

Marc losnations at comcast.net
Fri Sep 12 00:17:53 EDT 2003


The problem is that I have other objects in the rectangle that I'm basically
using as a holder. So if I use the closest function, then sometimes when I
have more than one object in the rectangle it will pick up the other
objects. Therefore I simply need a way of always knowing when the cursor is
within the bounds of the rectangle.

Like I say, I am doing it right now with a bunch of if statements. It works
fine. But it's sort of a brute force method. Seems kind of hackish. It just
seems like one of those things where there has to be a cleaner way.



"Gordon Airport" <uce at ftc.gov> wrote in message
news:ekCdneV55u9Ij_yiXTWJhA at comcast.com...
> Have you tried find_closest?
> Given a click event...
>
> x = cv.canvasx( event.x )
> y = cv.canvasy( event.y )
> cvid = cv.find_closest( x, y )[0]
> cv.itemconfig( cvid, fill = 'black' )
>
>






More information about the Python-list mailing list