from tkinter import * def p(): print(chk['variable']) root = Tk() var = IntVar() chk = Checkbutton(root, text = 'checkbutton', variable = var, command = p) chk.pack() root.mainloop()
variable= Associates a Tkinter variable to the button. When the button is pressed, the variable is toggled between offvalue and onvalue. Explicit changes to the variable are automatically reflected by the buttons. (variable/Variable)
37,743
社区成员
34,212
社区内容
加载中
试试用AI创作助手写篇文章吧