阙辉

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()

 

posted on 2018-06-25 14:10  真辉辉  阅读(398)  评论(0)    收藏  举报

导航