Bind mouse click action to the object on a canvas : Canvas : GUI Tk PYTHON examples


PYTHON examples » GUI Tk » Canvas »

 

Bind mouse click action to the object on a canvas


Bind mouse click action to the object on a canvas


from Tkinter import 

def onObjectClick(event):                  
    print 'Clicked', event.x, event.y, event.widget,
    print event.widget.find_closest(event.x, event.y)   

root = Tk()
canv = Canvas(root, width=100, height=100)
obj1 = canv.create_text(5030, text='Click me one')
obj2 = canv.create_text(5070, text='Click me two')

canv.tag_bind(obj1, '<Double-1>', onObjectClick)        
canv.tag_bind(obj2, '<Double-1>', onObjectClick)        
canv.pack()
root.mainloop()


           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo GUI Tk
» Canvas