我目前正在尝试创建一个 GUI 来比较两个不同文件夹之间的文件,并拥有一个我现在正在尝试构建的基本框架。
我在窗口的左侧、右侧和底部有三个框架,每个框架有两个复选按钮。我希望能够彼此独立地选择每个复选按钮,但是每次单击任何一个框架的第一个复选按钮时,其他框架的第一个复选按钮也会同时选择/取消选择。
为什么会这样,我如何让它们彼此独立工作?这是我的代码供参考:
from tkinter import *
root = Tk()
leftFrame = Frame(root, bg = "#4d94ff")
leftFrame.pack(side = LEFT, fill = BOTH)
rightFrame = Frame(root, bg = "#ff4d4d")
rightFrame.pack(side = RIGHT, fill = BOTH)
bottomFrame = Frame(root, bg = "#5cd65c")
bottomFrame.pack(side = BOTTOM)
check_L1 = Checkbutton(leftFrame, text = "C1", bg = "#4d94ff")
check_L2 = Checkbutton(leftFrame, text = "C2", bg = "#4d94ff")
check_R1 = Checkbutton(rightFrame, text = "C1", bg = "#ff4d4d")
check_R2 = Checkbutton(rightFrame, text = "C2", bg = "#ff4d4d")
checktype1 = Checkbutton(bottomFrame, text = "Check Type 1", bg = "#5cd65c")
checktype2 = Checkbutton(bottomFrame, text = "Check Type 2", bg = "#5cd65c")
check_L1.grid(row = 0)
check_L2.grid(row = 0, column = 1)
check_R1.grid(row = 0)
check_R2.grid(row = 0, column = 1)
checktype1.grid(row = 0)
checktype2.grid(row = 1)
root.mainloop()