Lazo Lab Sign up

App 5: Desktop App with Windows & Buttons / Build a notes app

Lesson 9 of 10

Shortcuts and status bar

Real apps have Ctrl+S to save and a status bar with a word count. bind() connects keys to functions.

Key points

  • root.bind("<Control-s>", ...)
  • A Label at the bottom as a status bar
  • Update it on every key press
status = tk.Label(root, anchor="w")
status.pack(fill="x")

def update_status(event=None):
    words = len(text.get("1.0", tk.END).split())
    status.config(text=f"{words} words")

text.bind("<KeyRelease>", update_status)
root.bind("<Control-s>", lambda e: save())

Your turn

Add Ctrl+S and a live word count.

Watch a video on thisOpens YouTube search results for “Shortcuts and status bar” in a new tab

Quiz · +10 XP

What does bind("<Control-s>", ...) do?

Log in to save progress and earn XP.