4.2、设置 Checkbutton 的事件处理函数
# command:指定事件处理函数
from Tkinter import *
def callCheckbutton():
print 'you check this button'
root = Tk()
# 指定事件处理函数
Checkbutton(root,
text = 'check python',
command = callCheckbutton
).pack()
root.mainloop()
# 不管 Checkbutton 的状态如何,此回调函数都会被调用
代码
from tkinter import *
def callC():
print("你选了复选框,阙辉!")
quehui = Tk()
Checkbutton(quehui,
text = '选择',
command = callC
).pack()
quehui.mainloop()


浙公网安备 33010602011771号