Monday, 15 September 2014

class - Python Detect shape over another shape -



class - Python Detect shape over another shape -

i need know how observe if oval beingness draged mouse come in on shape(rectangle).

class bloque(): # creates block def __init__(self, lista, ventana): self.espacio = ventana # assings canvas box = self.espacio.create_rectangle(x1, y1, x2, y2, width = 0) # creates block self.espacio.tag_bind(box, '<enter>', lambda e: print("passed over"))

this detects if mouse pass on block when drag other shape on block, it's not detected. how can create when drag other shape on block send me message?. thanks.

this solution assumes oval id stored in self.oval. note i've stored box id in instance variable self.box instead of local variable box.

class bloque(): # creates block def __init__(self, lista, ventana): self.espacio = ventana # assings canvas self.box = self.espacio.create_rectangle(x1, y1, x2, y2, width = 0) # creates block self.espacio.tag_bind(self.box, '<b1-motion>', self.detectintersection) def detectintersection(self, event): overlaps = self.espacio.find_overlapping(*self.espacio.bbox(box)) if self.oval in overlaps: print("passed over")

python class tkinter shape

No comments:

Post a Comment