Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何Checkbutton在 python 中获取 a 的状态?我有这个:
Checkbutton
def doSomething(): if #code goes here, if checkbutton is selected ... check = Checkbutton(window, text="Add both", onvalue = 1, offvalue = 0) check.pack(side="right")
您需要将Checkbox与变量相关联:
Checkbox
is_checked = IntVar() check = Checkbutton(window, text="Add both", onvalue=1, offvalue=0, variable=is_checked)
然后利用做你的检查,例如:
if is_checked.get(): # do something