How to get the checkbutton to respond to command? : <p>I have a button which adds a movable yellow circle and an off switch when pressed. I want the user to turn off and on the yellow circle, when the checkbutton is checked it will turn the circle to white and when the button is checked it will turn the circle yellow.</p>

<pre><code>from tkinter import *

root=Tk()
root.grid()
input_id=0
yco=212
canvas=Canvas(root,height=600,width=600)
canvas.grid()

def addInput():
   global input_id
   global yco
   input_id+=1
   yco+=50
   input_tag="input-%s"%input_id
   tags=("input",input_tag)
   canvas.create_oval(200,200,225,225,fill="WHITE",width=5,tag=tags)
   canvas.tag_bind(input_tag,"&lt;B1-Motion&gt;",lambda event,tag=input_tag:moveInput(event,tag))


   def checkStatus(status):
      if status.get()==0:
         canvas.delete(tags)
         canvas.create_oval(200,200,225,225,fill="YELLOW",width=5,tag=tags)
         canvas.tag_bind(input_tag,"&lt;B1-Motion&gt;",lambda event,tag=input_tag:moveInput(event,tag))
      else:
         canvas.delete(tags)
         canvas.create_oval(200,200,225,225,fill="WHITE",width=5,tag=tags)
         canvas.tag_bind(input_tag,"&lt;B1-Motion&gt;",lambda event,tag=input_tag:moveInput(event,tag))


   status=IntVar()
   statusCkbtn=Checkbutton(canvas,text="Off",command=checkStatus(status),variable=status,bg="white")
   statusCkbtn.var=status
   statusCkbtn.place(x=200,y=yco)


def moveInput(event, tag):
   x=event.x
   y=event.y
   coords=canvas.coords(tag)
   movex=x-coords[0]
   movey=y-coords[1]
   canvas.move(tag, movex, movey)


btn=Button(canvas,text="Add Input",command=lambda:addInput())
btn.place(x=100,y=100)
root.mainloop()
</code></pre>
