How to bind tkinter canvas image to a function?

Viewed 406

I've seen that it is possible to bind a label to a function so that if it's clicked, it does something. How can this be done using canvas.create_image method? When I tried it says that AttributeError: 'int' object has no attribute 'bind'. How is an image an integer?

1 Answers

Use the canvas.tag_bind method.

img = canvas.create_image()
canvas.tag_bind(img, '<Button-1>', callback)
Related