Python GUI----Checkbutton

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.