← VCE Software Development U3O1

Showing messages with messagebox

Pops up a message window to tell the user a result. Its partner messagebox.showerror() pops up an error, such as when a handler finds invalid input. Both need a title and a message.

Understanding Showing messages with messagebox in VCE Software Development U3O1

What it does: messagebox must be imported from tkinter before messagebox.showinfo() or messagebox.showerror() can be called. This is a validation error message in a handler: the check fails, so showerror() tells the user what went wrong. showinfo() is for telling the user about a normal result. showerror() is kept for problems such as invalid input. showinfo() opens a pop-up window. It needs a title (shown on the window bar) and a message (shown in the body). It does not print to the console.

Common mistakes: This is not valid Python import syntax. It should be 'from tkinter import messagebox' so messagebox.showinfo() can be used. The input is invalid, so the user should see an error pop-up. Use messagebox.showerror(t, m), not showinfo.

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 call shows a pop-up telling the user their quiz score was saved?
messagebox.showinfo("Saved", "Score saved")messagebox.showerror("Saved", "Score saved")
Matches
messagebox.showinfo("Your score is 90")
↓
showinfo() needs both a title and a message. Only one string is given, so Python raises a TypeError. Fix: messagebox.showinfo("Score", "Your score is 90").
Applying
Meanings
Term
messagebox.showinfo()
Meaning
Pops up a message window to tell the user a result. Its partner messagebox.showerror() pops up an error, such as when a handler finds invalid input. Both need a title and a message.
Practice
from tkinter import messagebox
Testing
Gaps
messagebox.("Result", "Saved!")
Check Answer
Spots
1import messagebox from tkinter
2def show():

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

The 'Penguin' badge — List Waddler, 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 call shows a pop-up telling the user their quiz score was saved?
A. messagebox.showinfo("Saved", "Score saved") ✓
B. messagebox.showerror("Saved", "Score saved")
showinfo() is for telling the user about a normal result. showerror() is kept for problems such as invalid input.
2. A button handler finds the user typed letters in an age box. Which call is the best choice?
A. messagebox.showerror("Error", "Age must be a number") ✓
B. messagebox.showinfo("Done", "Age must be a number")
A validation error message in a handler should use showerror(), so the pop-up clearly signals that something went wrong.
3. Which statement about messagebox.showinfo() is correct?
A. It takes only a variable name and prints it in the console.
B. It takes a title and a message to display. ✓
showinfo() opens a pop-up window. It needs a title (shown on the window bar) and a message (shown in the body). It does not print to the console.
4. Which line is the correct way to show an error pop-up in tkinter?
A. messagebox.showerror("Enter a number")
B. messagebox.showerror("Invalid", "Enter a number") ✓
showerror() needs both a title and a message, in that order. Leaving out one argument means the call is incomplete.
5. What must be done before messagebox can be used in a tkinter program?
A. from tkinter import messagebox ✓
B. import messagebox.showinfo()
messagebox is a tkinter module, so import it with from tkinter import messagebox. You then call messagebox.showinfo() or messagebox.showerror().

Match the Pairs

messagebox.showinfo("Result", "Total saved") → Pops up an information window titled Result that tells the user the total was saved.
messagebox.showerror("Invalid", "Enter a number") → Pops up an error window titled Invalid that tells the user their input was wrong.
Import messagebox from tkinter so pop-up message functions can be used in a program. → from tkinter import messagebox
A button handler checks the entry text and shows an error pop-up when the input is not a number. → if not age.isdigit(): messagebox.showerror("Error", "Age must be a number")
messagebox.showinfo("Your score is 90") → showinfo() needs both a title and a message. Only one string is given, so Python raises a TypeError. Fix: messagebox.showinfo("Score", "Your score is 90").
messagebox.showinfo("Error", "Invalid age entered") → showinfo() shows an information icon, which is wrong for invalid input. Fix: use messagebox.showerror("Error", "Invalid age entered") so the user sees an error pop-up.

Key Term

messagebox.showinfo()
Pops up a message window to tell the user a result. Its partner messagebox.showerror() pops up an error, such as when a handler finds invalid input. Both need a title and a message.

Fill in the Blanks

1. messagebox.showinfo("Result", "Saved!")
Hint: Type the function name that pops up a normal information message.
2. messagebox.showerror ("Error", "Enter a number")
Hint: Type the function name that pops up an error message window.
3. from tkinter import messagebox
Hint: Type the name of the tkinter module that provides pop-up message windows.
4. msg = "Saved" messagebox.showinfo("Info", msg)
Hint: Type the variable name that supplies the message text argument.
5. if not age.get().isdigit(): messagebox.showerror("Error", "Digits")
Hint: Type the keyword that makes the error branch run when the input is not all digits.

Spot the Error

Question 1
A import messagebox from tkinter
B def show():
C t, m = 'Result', 'Saved'
D messagebox.showinfo(t, m)
Line A — This is not valid Python import syntax. It should be 'from tkinter import messagebox' so messagebox.showinfo() can be used.
Question 2
A age = entry.get()
B t, m = 'Error', 'Numbers only'
C if not age.isdigit():
D messagebox.showinfo(t, m)
Line D — The input is invalid, so the user should see an error pop-up. Use messagebox.showerror(t, m), not showinfo.
Question 3
A def show_total():
B total = 5 + 3
C m = 'Total: ' + total
D messagebox.showinfo('Sum', m)
Line C — You cannot join a string and an integer with +, so this raises a TypeError. Use an f-string, f'Total: {total}', or str(total).
Question 4
A from tkinter import messagebox
B t, m = 'Done', 'File saved'
C messagebox.showInfo(t, m)
Line C — Python is case-sensitive. The function is showinfo with a lowercase i, so showInfo causes an AttributeError.
Question 5
A def oops():
B showerror(t, m)
C b = Button(win, command=oops)
Line B — Only messagebox was imported, so showerror on its own is not defined (NameError). Call it as messagebox.showerror(t, m).

Student with a class code? Join your class →