The Radiobutton is a standard Tkinter widget used to implement one-of-many selections. Radiobuttons can contain text or images, and you can associate a Python function or method with each button. When the button is pressed, Tkinter automatically calls that function or method.
button = Radiobutton(master, text=”Name on Button”, variable = “shared variable”, value = “values of each button”, options = values, …)
shared variable = A Tkinter variable shared among all Radio buttons
value = each radiobutton should have different value otherwise more than 1 radiobutton will get selected.
Radiobuttons, but not in the form of buttons, in form of button box. In order to display button box indicatoron/indicator option should be set to 0.
Background of these button boxes are light blue. Button boxes having white background as well as sunken are selected ones.
Code #2: Changing button boxes into standard radio buttons. For this remove indicatoron option.
These Radiobuttons are created using
tkinter.ttk that is why background option is not available but we can use style class to do styling.
Code #3: Adding Style to Radio Button using
You may observe that font style is changed as well as background and foreground colors are also changed. Here,
TRadiobutton is used in style class, it automatically applies styling to all the available Radiobuttons.
- Python GUI - tkinter
- Python | after method in Tkinter
- Python: Age Calculator using Tkinter
- Python-Tkinter Scrollbar
- Python Tkinter - Label
- Different messages in Tkinter | Python
- Python | GUI Calendar using Tkinter
- Python Tkinter Tutorial
- Python Tkinter - SpinBox
- Python Tkinter - Message
- Python - Tkinter askquestion Dialog
- Python Tkinter - ListBox Widget
- Python Tkinter - Scale Widget
- Collapsible Pane in Tkinter | Python
- Sentiment Detector GUI using Tkinter - Python
- Python Tkinter - Checkbutton Widget
- Python | winfo_ismapped() and winfo_exist() in Tkinter
- Python Tkinter - ScrolledText Widget
- Create a Yes/No Message Box in Python using tkinter
- Python | Create a GUI Marksheet using Tkinter
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : shubham_singh