Python Tkinter Radiobutton
The Radiobutton widget is used to implement one-of-many selection in the python application. It shows multiple choices to the user out of which, the user can select only one out of them. We can associate different methods with each of the radiobutton.
We can display the multiple line text or images on the radiobuttons. To keep track the user's selection the radiobutton, it is associated with a single variable. Each button displays a single value for that particular variable.
The syntax to use the Radiobutton is given below.
||The background color of the widget when it has the focus.
||The font color of the widget text when it has the focus.
||It represents the exact position of the text within the widget if the widget contains more space than the requirement of the text. The default value is CENTER.
||The background color of the widget.
||It is used to display the graphics on the widget. It can be set to any graphical or image object.
||It represents the size of the border.
||This option is set to the procedure which must be called every-time when the state of the radiobutton is changed.
||The mouse pointer is changed to the specified cursor type. It can be set to the arrow, dot, etc.
||It represents the font type of the widget text.
||The normal foreground color of the widget text.
||The vertical dimension of the widget. It is specified as the number of lines (not pixel).
||It represents the color of the focus highlight when the widget has the focus.
||The color of the focus highlight when the widget is not having the focus.
||It can be set to an image object if we want to display an image on the radiobutton instead the text.
||It represents the justification of the multi-line text. It can be set to CENTER(default), LEFT, or RIGHT.
||The horizontal padding of the widget.
||The vertical padding of the widget.
||The type of the border. The default value is FLAT.
||The color of the radio button when it is selected.
||The image to be displayed on the radiobutton when it is selected.
||It represents the state of the radio button. The default state of the Radiobutton is NORMAL. However, we can set this to DISABLED to make the radiobutton unresponsive.
||The text to be displayed on the radiobutton.
||It is of String type that represents the text displayed by the widget.
||The default value of this option is -1, however, we can set this option to the number of character which is to be underlined.
||The value of each radiobutton is assigned to the control variable when it is turned on by the user.
||It is the control variable which is used to keep track of the user's choices. It is shared among all the radiobuttons.
||The horizontal dimension of the widget. It is represented as the number of characters.
||We can wrap the text to the number of lines by setting this option to the desired number so that each line contains only that number of characters.
The radiobutton widget provides the following methods.
||It is used to turn of the radiobutton.
||It is used to flash the radiobutton between its active and normal colors few times.
||It is used to call any procedure associated when the state of a Radiobutton is changed.
||It is used to select the radiobutton.