4

I am writing a program which reads data form a file, and adjust the settings accordingly. This is how I created the checkbutton:

should_auto = BooleanVar()    
autodetect = Checkbutton(root, text="Autodetect", var=should_auto, onvalue = True, offvalue = False, command=toggle_delay)
autodetect.grid(row=0, column=2, padx=7, pady=5, sticky=W)

I then try to "check" it using:

autodetect.select()

but this returns following error:

Traceback (most recent call last):
  File "C:\Users\CedBook\Documents\GitHub\live-image-desktop-background\src\GUI.py", line 110, in <module>
    autodetect.select()
AttributeError: 'Checkbutton' object has no attribute 'select'

I have already also tried using autodetect.set(True), but then i get almost the same error, but Checkbutton object has no attribute 'set' I saw .select() on effbot.org, but maybe that is not for python 3?

2
  • use autodetect.set(1)? Commented Mar 5, 2014 at 9:58
  • still get the same error. Commented Mar 5, 2014 at 10:03

1 Answer 1

1

Can you set the value of the boolean instead?

should_auto.set(True)

should update the checkbox that relies on it.

Sign up to request clarification or add additional context in comments.

4 Comments

yup that would do it..you beat me to it ;)
autodtect.set(1) might have worked, but that was the button, not the variable. Thanks anyway both of you.
AttributeError: 'Checkbutton' object has no attribute 'set'
@Ath.Bar. it sounds like you're trying to set the value of the checkbutton not the variable backing it, See the OP where should_auto is a BooleanVar and is passed to the Checkbutton as the var keyword.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.