Goal for this part
By the end of this snapshot you will have a tiny desktop window that shows a greeting. That sounds small on purpose: GUI toolkits are easier to learn when you can see the event loop before databases and dialogs enter the picture.
Stackhaven starts as a short app.py. You create a root window, place a label, and call mainloop() so the app stays open and responds to the desktop.
What you should already know
You do not need prior Tkinter experience. You should be comfortable opening a terminal, running python3, and editing a .py file.
- You can run commands in a terminal
- You know how to save and run a Python file
- You have a desktop session (not a headless SSH-only box without display forwarding)
What Tkinter is doing for you
A desktop app draws widgets and waits for events: clicks, key presses, window closes. mainloop() is that wait loop. Without it, the window would flash and exit immediately.
import tkinter as tk
root = tk.Tk()
root.title("Stackhaven Library")
root.geometry("420x180")
label = tk.Label(root, text="Hello, Stackhaven!", font=("Segoe UI", 18))
label.pack(expand=True)
root.mainloop()How to run it and what you should see
Clone the teaching repo, move into 01-Getting-Started, and run python3 app.py. A desktop window titled Stackhaven Library should appear with the greeting. Close the window to stop the process.
git clone https://github.com/michaeldunga1/fcc-tkinter-library.git
cd fcc-tkinter-library/01-Getting-Started
python3 app.pyCommon mistakes and troubleshooting
If Python says it cannot import tkinter on Linux, install the Tk bindings package for your distro (often python3-tk). On remote servers without a display, Tkinter cannot open a window unless you forward X11/Wayland or use a local machine.