tkinter The Tkinter Radiobutton widget

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • radiobutton = tk.Radiobutton(parent, **kwargs)

Parameters

ParameterDescription
parenttkinter widgets exist in a hierarchy. Except for the root window, all widgets have a parent. Some online tutorials call this "master". When the widget is added to the screen with pack, place or grid, it will appear inside this parent widget.
commandfunction called each time the user changes the state of the radiobutton
indicatoron1 or True for radio buttons, 0 or False for button boxes
textText to display next to the radiobutton.
valueWhen the radiobutton is selected, the associated control variable is set to value.
variableControl variable the radiobutton shares with the other radiobutton of the group.

Remarks

These examples assume that tkinter has been imported with either import tkinter as tk (python 3) or import Tkinter as tk (python 2).

Reference:

enter image description here

To turn the above example into a “button box” rather than a set of radio buttons, set the indicatoron option to 0. In this case, there’s no separate radio button indicator, and the selected button is drawn as SUNKEN instead of RAISED:

enter image description here

-effbot



Got any tkinter Question?