← VCE Software Development U3O1

Choice controls: Checkbutton, Radiobutton and Combobox

A tkinter variable that stores the user's pick from a choice control (Checkbutton, Radiobutton or Combobox). Link it with variable= and read the choice with .get().

Understanding Choice controls: Checkbutton, Radiobutton and Combobox in VCE Software Development U3O1

What it does: The Checkbutton is linked to the BooleanVar using variable=, and .get() returns True when the box is ticked and False when it is not. Both buttons use variable=size, so they belong to the same group. Selecting one replaces the stored value and deselects the other. A Combobox uses the values= argument for its list of options. It comes from tkinter.ttk, so you write ttk.Combobox. tkinter variables such as StringVar, IntVar and BooleanVar are read with the .get() method. They have no .value attribute. Checkbutton and Radiobutton use variable=. A Combobox is a text-style control, so it uses textvariable= instead. Checkbuttons let the user tick any number of boxes. Radiobuttons sharing a variable allow only one choice.

Common mistakes: StringVar is a class, so it must be called with brackets to create the variable object. It should be choice = tk.StringVar(). variable= needs the tkinter variable object, not a string with its name. Remove the quotes: cb.config(variable=agree).

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 125–141) and word search (Modules 114–141).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which line creates a variable to store whether a Checkbutton is ticked?
agree = tk.Checkbutton()agree = tk.BooleanVar()
Matches
Radiobutton(root, text="Small", variable=size) Radiobutton(root, text="Large", variable=size)
↓
No value= is given, so the buttons have no distinct value to store and cannot be told apart. Add value="S" and value="L".
Applying
Meanings
Term
StringVar()
Meaning
A tkinter variable that stores the user's pick from a choice control (Checkbutton, Radiobutton or Combobox). Link it with variable= and read the choice with .get().
Practice
import tkinter as tk
Testing
Gaps
ok = tk.()
Check Answer
Spots
1choice = tk.StringVar
2r1 = tk.Radiobutton(win)

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Cosmic Dragon' badge — Orbit Master, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which line creates a variable to store whether a Checkbutton is ticked?
A. agree = tk.BooleanVar() ✓
B. agree = tk.Checkbutton()
A BooleanVar holds True or False. You link it to the Checkbutton with variable=agree. The Checkbutton itself is the control, not the storage.
2. A Radiobutton group lets the user pick one size. How do you make the buttons work as one group?
A. Give every Radiobutton its own separate variable but the same value=
B. Give every Radiobutton the same variable=size but a different value= ✓
Sharing one variable is what links the group, so only one button can be selected. Each button needs its own value so you can tell which one was picked.
3. Which Combobox call correctly supplies the list of options?
A. ttk.Combobox(root, options=["Red", "Blue"])
B. ttk.Combobox(root, values=["Red", "Blue"]) ✓
A Combobox uses the values= argument for its list of options. It comes from tkinter.ttk, so you write ttk.Combobox.
4. A StringVar called colour is linked to a choice control. How do you read the user's choice?
A. colour.get() ✓
B. colour.value
tkinter variables such as StringVar, IntVar and BooleanVar are read with the .get() method. They have no .value attribute.
5. How do you link a Combobox to a StringVar called pick?
A. ttk.Combobox(root, textvariable=pick) ✓
B. ttk.Combobox(root, variable=pick)
Checkbutton and Radiobutton use variable=. A Combobox is a text-style control, so it uses textvariable= instead.

Match the Pairs

Radiobutton(root, text="Small", variable=size, value="S") → Creates one radio option that sets the shared variable size to "S" when the user selects it
ttk.Combobox(root, textvariable=colour, values=["Red", "Blue"]) → Creates a drop-down list whose chosen item is stored in the variable colour
A Checkbutton stores True or False in a BooleanVar, so you read the tick state with .get() → agree = BooleanVar() Checkbutton(root, text="I agree", variable=agree) print(agree.get())
A group of Radiobuttons shares ONE variable so that only one option can be selected at a time → size = StringVar() Radiobutton(root, text="S", variable=size, value="S") Radiobutton(root, text="L", variable=size, value="L")
Radiobutton(root, text="Small", variable=size) Radiobutton(root, text="Large", variable=size) → No value= is given, so the buttons have no distinct value to store and cannot be told apart. Add value="S" and value="L".
choice = StringVar() print(choice) → The variable is printed instead of reading its contents. Use choice.get() to get the user's pick.

Key Term

StringVar()
A tkinter variable that stores the user's pick from a choice control (Checkbutton, Radiobutton or Combobox). Link it with variable= and read the choice with .get().

Fill in the Blanks

1. ok = tk.BooleanVar() tk.Checkbutton(win, text="Yes", variable=ok)
Hint: Type the tkinter variable class that stores a True/False tick state.
2. tk.Radiobutton(win, variable=size, value="S")
Hint: Type the argument name that sets what this radio button stores in the variable when selected.
3. size = tk.StringVar(value="S") tk.Radiobutton(win, variable=size, value="M")
Hint: Type the variable name that every radio button in the group must share.
4. box = ttk.Combobox(win, values=["S", "M"])
Hint: Type the argument name that supplies the list of options in the dropdown.
5. size = tk.StringVar(value="S") print("Chosen:", size.get())
Hint: Type the method that reads the user's current choice from the variable.

Spot the Error

Question 1
A choice = tk.StringVar
B r1 = tk.Radiobutton(win)
C r1.config(text="Yes", value="y")
D r1.config(variable=choice)
Line A — StringVar is a class, so it must be called with brackets to create the variable object. It should be choice = tk.StringVar().
Question 2
A agree = tk.BooleanVar()
B cb = tk.Checkbutton(win)
C cb.config(variable="agree")
D print(agree.get())
Line C — variable= needs the tkinter variable object, not a string with its name. Remove the quotes: cb.config(variable=agree).
Question 3
A size = tk.StringVar()
B cb = ttk.Combobox(win)
C cb.config(textvariable=size)
D cb.values = ["S", "M"]
Line D — A Combobox list of options is set with the "values" option, not by creating a Python attribute. It should be cb["values"] = ["S", "M"].
Question 4
A pick = tk.StringVar()
B pick.set("Medium")
C print(pick.value())
Line C — A tkinter variable has no .value() method. The user's choice is read with .get(), so it should be print(pick.get()).
Question 5
A pet = tk.StringVar()
B r1 = tk.Radiobutton(win)
C r1.config(textvariable=pet)
D r2 = tk.Radiobutton(win)
E r2.config(variable=pet)
Line C — textvariable sets the text shown on a control. A Radiobutton stores the user's choice using variable=, so it should be r1.config(variable=pet), the same as r2.

Student with a class code? Join your class →