我正在寫一個程序,它從一個文件讀取數據,並相應地調整設置。這是我創建的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