App 5: Desktop App with Windows & Buttons / Build a calculator
Lesson 2 of 10
Widgets and layout
Labels show text, Entries take typing, Buttons run code. grid() places widgets in rows and columns, perfect for a calculator.
Key points
- tk.Label, tk.Entry, tk.Button
- grid(row=, column=) for layouts
- sticky="nsew" stretches widgets
entry = tk.Entry(root, font=("Arial", 20), justify="right")
entry.grid(row=0, column=0, columnspan=4, sticky="nsew")
tk.Button(root, text="7").grid(row=1, column=0, sticky="nsew")Your turn
Make a window with an Entry across the top and one button below it.
Quiz · +10 XP
Which layout method places widgets in rows and columns?
Log in to save progress and earn XP.