I would like some help with something simple: A tkinter checkbox that does have a command attached <--this simple example is always mentioned but never shown in tutorials on the web.
I have:
from tkinter import *
def activateMotors(active):
scale.config(state=active)
root = Tk()
root.wm_title('Servo Control')
motorsOn= IntVar()
motorsCheck=Checkbutton(root,text="Motors ON(checked)/OFF(unchecked)", variable=motorsOn, command=activateMotors)
motorsCheck.pack()
scale = Scale(root, from_=0, to=180,
orient=HORIZONTAL,label="Motor #",state=DISABLED)
scale.pack()
root.mainloop()
This does not work. Sure the window comes up but when I click on the checkbox I get "TypeError activateMotors() missing 1 required positional argument 'active' "
Can anybody correct this so that we can have one operational checkbox example with commands?
Aucun commentaire:
Enregistrer un commentaire