如何在 Tkinter 中设置火柴盒,所以 "match all" 有效,但是当我想按集合中的任何火柴盒时,我可以打破规则吗?

how to set matchboxes in Tkinter, so "match all" works, but when I want to press any matchbox from the set, I can break the rule?

我的问题是:我不知道如何设置我的 Checkbutton 以使 Checkbutton 之一可以匹配所有框(这部分已完成),但是当我想取消匹配任何其他框时,这是可能的。当我 运行 我的代码部分带有“所有框”选项时,我可以“选中”它们,或者全部取消,但是在按下“所有框”按钮后,我无法取消选中任何其他“所有框”以外的框。

我的代码的关键部分:

onevar = tk.BooleanVar(value=False)
def select_all(): # select all `tk.Checkbutton`
    check_buttons_list = [twovar, threevar, fourvar, fivevar, sixvar, sevenvar]
    for name in check_buttons_list:
        if onevar.get() == True:
            name.set(1)
        if onevar.get() == False:
            name.set(0)

        #below the problem, I don't know what should I write here:
        if name.get() != onevar.set():
            return name.set()

twovar = tk.BooleanVar(value=True)
threevar = tk.BooleanVar(value=True)
fourvar = tk.BooleanVar(value=True)
fivevar = tk.BooleanVar(value=True)
sixvar = tk.BooleanVar(value=True)
sevenvar = tk.BooleanVar(value=True)

one = tk.Checkbutton(
        content,
        text="Match ALL",
        variable=onevar,
        onvalue=True,
        bg="red",
        fg="black",
        command=select_all,
        font=font.Font(family='Helvetica', size="9", weight='bold')
        )
two = tk.Checkbutton(content, text="box1", variable=twovar, onvalue=True, command=select_all)
three = tk.Checkbutton(content, text="box2", variable=threevar, onvalue=True, command=select_all)
four = tk.Checkbutton(content, text="box3", variable=fourvar, onvalue=True, command=select_all)
five = tk.Checkbutton(content, text="box4", variable=fivevar, onvalue=True, command=select_all)
six = tk.Checkbutton(content, text="box5", variable=sixvar, onvalue=True, command=select_all)
seven = tk.Checkbutton(content, text="box6", variable=sevenvar, onvalue=True, command=select_all)

enter image description here

我找到了解决问题的方法:

def select_all(): # select all `tk.Checkbutton`
    check_buttons_list = [twovar, threevar, fourvar, fivevar, sixvar, sevenvar]
    for name in check_buttons_list:
        if onevar.get() == True:
            for name in check_buttons_list:
                name.set(value=True) # instead of `value=True` can be `1`
        if onevar.get() == False:
            pass

onevar = tk.BooleanVar(value=False)
twovar = tk.BooleanVar(value=False)
threevar = tk.BooleanVar(value=False)
fourvar = tk.BooleanVar(value=False)
fivevar = tk.BooleanVar(value=False)
sixvar = tk.BooleanVar(value=False)
sevenvar = tk.BooleanVar(value=False)