[Tkinter-discuss] get quickly, very fast and directly items in a canvas from a moving button mouse

Mister Vanhalen mistervanhalen at gmail.com
Sat Feb 4 14:33:43 CET 2012


Hello everyone,

I have got a canvas, where I created some items (rectangles and letters). I
want to catch quickly and directly every item when I move my mouse holding
a button.
I managed to do something but when the movement is too fast, all items are
not selected....

Here is my code
event is from a bind of
canvas.bind('<B1-Motion>', lambda event,a="B1m":self.select(event, a))

def select(self, event, typeofevent):
   #=======================================================================
   # get the canvas object
   #=======================================================================
   canvas = event.widget

   #=======================================================================
   # find object close to mouse
   #=======================================================================
   x = canvas.canvasx(event.x)
   y = canvas.canvasy(event.y)
   item =  canvas.find_closest(x, y, halo=None, start=None)


This code works but when my mouse moves too fast, all items are not select.
I think self.select is called every x milliseconds, so when it is too fast,
it misses some items.
Is there a solution to manage that? I want to get item directly when my
mouse is over and button is held.

Thank you for your help,

Eduard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20120204/8b610fb3/attachment.html>


More information about the Tkinter-discuss mailing list