from Tkinter import *
window = Tk()
CheckVar1 = IntVar()
cbttn = Checkbutton(text="Caps?", variable = CheckVar1, \
onvalue = 1, offvalue = 0, height=5, \
width = 20)
cbttn.grid(row=3, column=0)
while True:
if CheckVar1 == 0:
a = Button(text="a").grid(column=1)
b = Button(text="b").grid(column=1)
c = Button(text="c").grid(column=1)
d = Button(text="d").grid(column=1)
e = Button(text="e").grid(column=1)
f = Button(text="f").grid(column=1)
g = Button(text="g").grid(column=1)
if CheckVar1 == 1:
A = Button(text="A").grid(column=1)
window.mainloop()#makes everything work
我想了解如何根据 的值来显示不同的按钮CheckVar1
。我没有错误,但我想要工作的代码是if CheckVar1 == 0:
and if CheckVar1 == 1
。