标签:python
from tkinter import * root = Tk() Checkbutton(root,text = 'python').pack() root.mainloop()
from tkinter import * def callCheckbutton(): print ('you check this button') root = Tk() Checkbutton(root,text = 'check python',command = callCheckbutton).pack() #不管Checkbutton的状态如何,此回调函数都会被调用 root.mainloop()
from tkinter import * root = Tk() #将一整数与Checkbutton的值绑定,每次点击Checkbutton,将打印出当前的值 v = IntVar() def callCheckbutton(): print (v.get()) Checkbutton(root, variable = v, text = 'checkbutton value', command = callCheckbutton).pack() root.mainloop()
from tkinter import * root = Tk() #将一字符串与Checkbutton的值绑定,每次点击Checkbutton,将打印出当前的值 v = StringVar() def callCheckbutton(): print v.get() Checkbutton(root, variable = v, text = 'checkbutton value', onvalue = 'python', #设置On的值 offvalue = 'tkinter', #设置Off的值 command = callCheckbutton).pack() root.mainloop()
标签:python
原文地址:http://blog.csdn.net/a359680405/article/details/45081409