igmochang
igmochang

Reputation: 97

How to bind tkinter canvas image to a function?

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?

Upvotes: 2

Views: 1060

Answers (1)

Novel
Novel

Reputation: 13729

Use the canvas.tag_bind method.

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

Upvotes: 3

Related Questions