我正在写一个程序,它从一个文件读取数据,并相应地调整设置。这是我创建的checkbutton:Tkinter checkbutton.select()不工作Checkbutton(Python 3)
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)
然后我尝试 “检查”,它使用:
autodetect.select()
但这返回以下错误:
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'
我已经还试图使用autodetect.set(True)
,但后来我得到几乎相同的错误,但Checkbutton object has no attribute 'set'
我看到了effcot.org上的.select(),但也许这不是python 3?
使用'autodetect.set(1)'? – Gogo
仍然会得到相同的错误。 – user3315473