I've been trying to make a function run when I click a rectangle on a tk canvas.
Here is the code:
from tkinter import * window = Tk() c = Canvas(window, width=300, height=300) def clear(): canvas.delete(ALL) playbutton = c.create_rectangle(75, 25, 225, 75, fill="red") playtext = c.create_text(150, 50, text="Play", font=("Papyrus", 26), fill='blue') c.pack() window.mainloop() does anyone know what I should do?
bindmethod?.tag_bindmethod here'current'tag for theitemconfigurecall. This should be much more efficient than making a separate tag for each item,.tag_binding them all and then checking the item ID in the event handler (if that information is even available).