A window is the main bounded area where a GUI program displays content and controls. In tkinter, you create it, set its size, title, and background, then keep it running for interaction. section 37.1 section 37.2
Listing 37.1. Creating a window
import tkinter #1
window = tkinter.Tk() #2
window.geometry("800x200") #3
window.title("My first GUI") #4
window.configure(background="grey") #5
window.mainloop() #6
This small listing creates an 800-by-200 tkinter window, names it, colors it gray, and starts its event loop. section 37.2
A basic window setup follows this sequence:
- Create the window with tkinter.Tk(). section 37.2
- Set its dimensions, title, and background color. section 37.2
- Add widgets such as buttons, menus, text boxes, labels, or canvases, then connect their events to functions. section 37.1 section 37.5
A practical window project
Build a phonebook window with name, phone, and email text boxes, Add and Show buttons, and a label for displaying contacts. section 37.5



