1. A simple example of Checkbutton
From tkinter Import *root = Tk () Checkbutton (root,text = ' python '). Pack () Root.mainloop ()
2. Set the callback function for Checkbutton
From Tkinter import *def Callcheckbutton (): print (' I check this button ') root = Tk () Checkbutton (root,text = ' Check P Ython ', command = Callcheckbutton). Pack () #不管Checkbutton的状态如何, this callback function will be called root.mainloop ()
3. Gets the value of Checkbuton on and off. Default defaults are 1 and 0, respectively
From tkinter Import *root = Tk () #将一整数与Checkbutton的值绑定, each time you click Checkbutton, the current value of V = Intvar () def Callcheckbutton () will be printed: Print (V.get ()) Checkbutton (root, variable = v, text = ' Checkbutton value ', command = Callcheckbutton). Pack () Root.mainloop ()
From tkinter Import *root = Tk () #将一字符串与Checkbutton的值绑定, each time you click Checkbutton, the current value of V = stringvar () def Callcheckbutton () will be printed: print V.get () Checkbutton (root, variable = v, text = ' Checkbutton value ', onvalue = ' python ', # Set the value of on offvalue = ' Tkinter ', #设置Off的值 command = Callcheckbutton). Pack () Root.mainloop ()
Python GUI----Checkbutton