我正在嘗試創建一個小桌面應用程序。在主窗口我有四個複選框,每個複選框具有值變量(1 0爲關,對):禁用Tkinter中其他複選框的複選框
random_cards = IntVar()
random_stacks = IntVar()
flip_cards = IntVar()
wildcard = IntVar()
randomize_cards_checkbutton = Checkbutton(text="Randomize cards", variable=random_cards).grid(row=0, column=0, in_=options, sticky=W)
randomize_stacks_checkbutton = Checkbutton(text="Randomize stacks", variable=random_stacks).grid(row=1, column=0,in_=options, sticky=W)
wildcard_checkbutton = Checkbutton(text="Wildcard", variable=wildcard).grid(row=2, column=0, in_=options, sticky=W)
flip_cards_checkbutton = Checkbutton(text="Flip cards", variable=flip_cards).grid(row=3, column=0, in_=options, sticky=W)
我想要的行爲是,如果wildcard_checkbutton
是上,兩個複選框randomize_cards_checkbutton
和randomize_stacks_checkbutton
是禁用(灰色),反之亦然。現在我不知道如何使這個功能運行「所有時間」
def check_checkbuttons(random_cards, random_stacks, wildcard):
if wildcard == 1:
randomize_cards_checkbutton.configure(state=DISABLED)
randomize_stacks_checkbutton.configure(state=DISABLED)
elif random_cards == 1 or random_stacks == 1:
wildcard_checkbutton.configure(state=DISABLED)
:我寫的小功能這一點。我如何實現它,所以這個功能一直在被檢查?