Diese Aussage kommt mir sehr falsch vor, obwohl ich keine Ahnung habe wie "item handles" aussehen. Anscheinend dürfen Tags nicht wie Zahlen aussehen, so ist im folgenden Code der Tag 't2' nicht ersetzbar durch '2':Tags are symbolic names attached to items. Tags are ordinary strings, and they can contain anything except whitespace (as long as they don’t look like item handles)
Code: Alles auswählen
import tkinter as t
def klick(cv): cv.itemconfig('t2',outline='blue')
fenster = t.Tk()
cv = t.Canvas(fenster)
cv.pack()
#
cv.create_rectangle(50,50, 200,200, width=5,tag='t2',outline='red')
cv.bind('<Button-1>',lambda event: klick(cv))
fenster.mainloop()