I'm trying to change the state of an array of objects on a tkinter canvas widget but require a delay before the change takes effect. When defining the change_color() function with no parameters, the behaviour is as expected, so I first see the canvas and the objects in their initial state followed by the delay, and then the objects in their final state. When I add a parameter to the function definition and later call it passing it an argument to select which object to change, the final result is ok but there's no initial state or delay displayed on the canvas. Is it possible to pass arguments to functions called from Tkinter?
# LED simulation using tkinter canvas widget
from tkinter import *
root = Tk()
root.geometry('640x480')
root.title('LED Simulation')
canvas = Canvas(width=640, height=480, bg='black')
canvas.pack()
# create LED objects on the canvas in the OFF state (dark red)
d7 = canvas.create_oval(50, 50, 75, 75, fill='dark red')
d6 = canvas.create_oval(100, 50, 125, 75, fill='dark red')
d5 = canvas.create_oval(150, 50, 175, 75, fill='dark red')
d4 = canvas.create_oval(200, 50, 225, 75, fill='dark red')
d3 = canvas.create_oval(250, 50, 275, 75, fill='dark red')
d2 = canvas.create_oval(300, 50, 325, 75, fill='dark red')
d1 = canvas.create_oval(350, 50, 375, 75, fill='dark red')
d0 = canvas.create_oval(400, 50, 425, 75, fill='dark red')
# changes the state of an LED from OFF to ON (red)
def change_color(led):
canvas.itemconfig(led, fill='red')
# wait for 1 sec, then change state to ON
root.after(1000, change_color(d3))
root.mainloop()