我注意到,当点击未勾选的复选框时,在翻转到完全检查之前,该框切换到“半状态”。它看起来像这样:Python TKinter Checkbutton Half States
有什么办法防止这种情况?因为这个原因,检查/取消检查的时间比它应该的时间要长。
#!/usr/bin/python
from random import randint
from Tkinter import *
# Set up main window settings
master = Tk()
master.title ("Window")
master.resizable(width = FALSE, height = FALSE)
def femaleOption():
maleCheckbox.deselect()
def maleOption():
femaleCheckbox.deselect()
#Create female checkbox
femaleIsChecked = IntVar()
femaleCheckbox = Checkbutton(master, text = "Female", command = femaleOption, variable = femaleIsChecked)
femaleCheckbox.select()
#Create male checkbox
maleCheckbox = Checkbutton(master, text = "Male", command = maleOption)
femaleCheckbox.pack()
maleCheckbox.pack()
master.mainloop()
你在哪个平台上?还有其他复选框绑定到相同的'IntVar'吗?只是有一个复选框,我不能在我的Mac上重现,如果有更多的代码需要获得该状态[请包括它](https://stackoverflow.com/help/mcve) –
请创建一个[mcve] –
我在苹果电脑。我会尽快用更多的代码更新这篇文章。 –