Leave the sandbox.
Build real windows.
Today your code runs on your own laptop, in VS Code, like real programmers. And it doesn't just print: it opens popups and windows with buttons.
> boot sequence
- Download
Click the green button. The zip lands in
Downloads. - Extract
Right-click the zip → Extract All… Don't work inside the zip!
- Open folder
VS Code → File → Open Folder… → pick the
agent-terminalfolder. - Open a file
Click
00_hello.pyin the list on the left. - Run ▶
The triangle in the top right. Your program talks to you in the terminal at the bottom.
> files
> cheat sheet
messagebox.showinfo(t, m) | popup with a message (also showwarning, showerror) |
messagebox.askyesno(t, m) | gives back True or False |
tk.Label(window, text=…) | text on the window |
tk.Entry(window) | a box to type in (show="*" hides it) |
tk.Button(…, command=f) | calls f on click. No ()! |
widget.pack() | put it in the window, top to bottom |
box.get() | read what is typed (always text) |
w.config(text=…, fg=…) | change a widget after it exists |
window.after(ms, f) | call f later, in milliseconds |
window.mainloop() | wait for clicks. The last line. |
> something broke
The Microsoft Store opened / "Python was not found"
Don't type python in the terminal. Use the ▶ button. If it still fails: Ctrl+Shift+P → Python: Select Interpreter → pick the one that says Python 3.
There is no ▶ button
The file must end in .py, and the Python extension must be installed (Extensions icon on the left, search "Python").
Popups keep coming and won't stop
Click inside the terminal and press Ctrl+C. Or click the bin icon on the terminal to kill it.
I ran it but no window appeared
Look at the taskbar: it may be behind VS Code. Is window.mainloop() the last line?
My function runs once at the start, and not on click
You wrote command=check_login(). The brackets call it right now. Write the name only:
tk.Button(window, text="LOGIN", command=check_login)
A red error in the terminal
Read the last line first: it says what went wrong. The line above it says which line of your file. Ctrl+click the file name to jump there.