작은 데스크탑 응용 프로그램을 만들려고합니다. 기본 창에서 내가 네 체크 박스를 가지고, 각각의 체크 박스 (온 오프 0, 1) 값을 가진 변수가 있습니다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)
지금이 함수를 "항상"실행하는 방법을 모르겠다. 이 기능을 항상 검사하도록 구현하려면 어떻게해야합니까?