所以问题是if
函数不能工作。它完全忽略所有值的变化,并且根本不改变任何值。这个代码怎么了?你知道吗
import tkinter as tk
root = tk.Tk()
CheckVar4 = tk.IntVar()
CheckVar5 = tk.IntVar()
C4 = tk.Checkbutton(root, text = "Medium terms", variable = CheckVar4, \
onvalue = 1, offvalue = 0, height=1, \
width = 12)
C5 = tk.Checkbutton(root, text = "Hard terms", variable = CheckVar5, \
onvalue = 1, offvalue = 0, height=1, \
width = 8)
if CheckVar4.get() == 1:
CheckVar5.set(0)
if CheckVar5.get() == 1:
CheckVar4.set(0)
root.mainloop()
也许你想用单选按钮代替?来自here的示例如下:
相关问题 更多 >
编程相关推荐