Python GUI----Radiobutton

Source: Internet
Author: User

RadioButton is a radio button, that is, only one button is selected within the same group, and when one button is selected in the group, the other buttons are automatically changed to unchecked, unlike other controls: It has the concept of a group

1. Create a simple RadioButton

Do not specify binding variables, each RadioButton as a group

From tkinter Import *root = Tk () Radiobutton (root,text = ' python '). Pack () Radiobutton (root,text = ' tkinter '). Pack () Radiobutton (root,text = ' widget '). Pack () Root.mainloop ()

2. Create a RadioButton group and use the binding variable to set the selected button
From tkinter Import *root = Tk () #创建一个Radiobutton组, create three RadioButton, and bind to an integer variable v# select value=1 Button v = Intvar () v.set (1) for I in Range (3):    Radiobutton (root,variable = v,text = ' Python ', value = i). Pack () Root.mainloop ()
3. Create two different groups

From tkinter Import *root = Tk () Vlang = Intvar () VOS = Intvar () vlang.set (1) vos.set (2) for V in [Vlang,vos]:                          #创建两个组    For I in range (3):                         #每个组含有3个按钮        Radiobutton (root,                    variable = V,                    value = i,                    text = ' python ' + str (i) 
   
    ). Pack () Root.mainloop ()
   

4.Radiobutton Another useful property is Indicatoron, which by default is 1, and if you change this property to 0, its appearance is sunken
From tkinter Import *root = Tk () v = Intvar () v.set (1) for I in Range (3):    Radiobutton (root,                    variable = v,                    indica Toron = 0,                    text = ' Python & tkinter ',                    value = i                    ). Pack () Root.mainloop ()




Python GUI----Radiobutton

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.