【发布时间】:2014-03-05 09:51:52
【问题描述】:
我正在编写一个程序,它从文件中读取数据,并相应地调整设置。这就是我创建检查按钮的方式:
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' 我在 effbot.org 上看到了 .select(),但也许这不适用于 python 3?
【问题讨论】:
-
使用
autodetect.set(1)? -
仍然出现同样的错误。
标签: python checkbox widget tkinter tk