Radiobutton

Radiobutton is a widget that lets us choose an option from multiple options. Tkinter provides Radiobutton using which we can display multiple options in our GUI application. 

Syntax: 

tk.Radiobutton(text=some_name,value=give_name_that_of_text,variable=Tkinter_Variable)

for option in [“Brown”,”Black”,”Orange”,”Green”,”Red”]:

    rd = tk.Radiobutton(root,text=”%s” %option,value=option,variable=choice)

    rd.pack()

In order to display a Variable for each Radiobutton, we shall initialize Tkinter String Variable. Using String Variable we can perform the set and get method. Initially using String Variable we shall initialize Purple as the default color.

Syntax:

var = tk.StringVar()
choice = tk.StringVar(root,"purple") # initialize

# after button click:
color = choice.get()

How To Change Multiple Background Colours In Tkinter?

In this article, we shall see how to change or switch between Multiple Background colors in Tkinter

Similar Reads

Radiobutton:

Radiobutton is a widget that lets us choose an option from multiple options. Tkinter provides Radiobutton using which we can display multiple options in our GUI application....

Canvas:

A Tkinter canvas can be used to draw in a window, create images and add color....

Button:

The button is used to trigger events in the GUI applications. You can add a command as the argument which calls the function to be executed on a button click. In simple words, Button is used to toggle events....