Level 2 · guizero
Mood & Tip Calculator App
A small window app with buttons and text — a simple GUI. Run the file, click the buttons, and see what happens.
What it teaches: GUI apps, buttons, input
How to run
Starter file: starter_guizero_app.py
python starter_guizero_app.pyStarter code
"""
LEVEL 2 - GUIZERO
Starter: Mood & Tip Calculator App
A small window app with buttons and text - a simple GUI (Graphical
User Interface). Run this file, click the buttons, and see what happens.
Your job: change it, upgrade it, make it yours!
"""
from guizero import App, Text, PushButton, TextBox, Box
app = App(title="Level 2 - My App", width=320, height=280, bg="lightyellow")
Text(app, text="Bill Splitter", size=20, font="Arial", color="black")
box = Box(app, layout="grid")
Text(box, grid=[0, 0], text="Bill amount:")
bill_input = TextBox(box, grid=[1, 0], width=10)
Text(box, grid=[0, 1], text="Number of people:")
people_input = TextBox(box, grid=[1, 1], width=10)
result_text = Text(app, text="", size=16, color="darkgreen")
def calculate():
try:
bill = float(bill_input.value)
people = int(people_input.value)
if people <= 0:
result_text.value = "Need at least 1 person!"
return
tip = bill * 0.15 # 15% tip
total_per_person = (bill + tip) / people
result_text.value = f"Each person pays: ${total_per_person:.2f}"
except ValueError:
result_text.value = "Please enter numbers only."
PushButton(app, text="Calculate", command=calculate)
app.display()
# ---------------------------------------------------------------
# LEVEL UP! Try one (or more) of these upgrades:
# 1. Add a Slider to choose the tip percentage instead of a fixed 15%.
# 2. Add a button that clears both text boxes.
# 3. Change the colors, fonts, or window size to make your own theme.
# 4. Add a second window (App) that pops up with a "thank you" message.
# 5. Turn this into a different app entirely: a BMI calculator, a
# temperature converter (C to F), or a simple quiz with score.
# 6. Ask your AI tool: "How do I add an image or icon to my guizero app?"
# ---------------------------------------------------------------
Challenge ideas
Easy
- Change the app title, colors, and window size.
- Change the tip percentage or add a fixed service fee.
Medium
- Add a Slider widget so users can choose their own tip percentage.
- Add input validation messages (e.g. red text for errors).
- Turn it into a unit converter (miles <-> km, or C <-> F).
Hard
- Add multiple "pages" using separate App windows or Box show/hide.
- Save results to a text file using Python's built-in open() function.
- Build a simple quiz app: show a question, take an answer, keep score.
Ask your AI tool
“How do I make a guizero app that saves what the user typed to a file?”