Animation5

Change the colour of your object with the fill command

In this example we have added the fill command after the coordinates to change colour.

Flashing Colours

you will need to import random at the top for this to work

blob2=win.create_rectangle(150,150,200,200, fill="red")

col=["red","blue","green"] #create a list of colours

blob2=win.create_rectangle(150,150,200,200, fill="red") #create rectangle in blob2 variable

for i in range(60): #60 repeat loops

win.move(blob2,0,-2) #move blob2 -2 on y axis

changecol=random.choice(col) #make a random choice from col list and put it into changecol variable

win.itemconfig(blob2, fill=changecol) #update blob2 with new random choice colour

tk.update() #update the window

time.sleep(0.05) #short time delay to slow things down

Remember this will only work if it inside a canvas with mainloop at the bottom