Changing the colour on click of a tkinter rectangle on click in python Changing the colour on click of a tkinter rectangle on click in python tkinter tkinter

Changing the colour on click of a tkinter rectangle on click in python


Name it and then refer to it through itemconfig, like this:

myrectangle = canvas.create_rectangle(100, 100, 400, 400, fill='black')canvas.itemconfig(myrectangle, fill='red')