user8435959 user8435959 -3 years ago 103
Python Question

Allowing multiple selection of radio buttons

How would I change my code to allow multiple buttons to be selected, rather than limiting to one being selected.

from tkinter import *

master = Tk()
master.title("Interests")
v = IntVar()

MODES = [
("Monochrome", "1"),
("Grayscale", "2"),
("True color", "3"),
("Colour separation", "4"),
]

v = StringVar()
v.set("0") # sets all visable buttons to unchecked
for text, mode in MODES:
b = Radiobutton(master, text=text, variable=v, value=mode)
b.pack(anchor=W)

Answer Source

It has been a convention for decades that radiobuttons are for making a single selection from a set of choices. Checkbuttons are for allowing multiple selections.

You need to switch from radiobuttons to checkbuttons. Each checkbutton needs to be given its own variable.

Here is an article by a well known usability expert which covers the use of each type of button:

https://www.nngroup.com/articles/checkboxes-vs-radio-buttons/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download