liveBook · Manning

Window

As explained in Get Programming: Learn to code with Python

A window is a bounded region of a graphical interface in which an application displays content and controls.

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

How Get Programming: Learn to code with Python covers it

How deep it goes
Explains creation, sizing, titling, coloring, and widget placement, while deferring detailed widget behavior to event handlers.
Examples
Uses an 800-by-200 gray window and a phonebook interface with text boxes, buttons, and a label.
What it assumes
Assumes basic Python use while introducing GUI libraries, widgets, and event-driven interaction.
What you can do after
Build a basic tkinter window and extend it into an interactive application with widgets.
How it connects
Connects windows with tkinter, widgets, event handlers, canvases, and graphical user interfaces.

Also explained in

Compare how 4 books explain window →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Get Programming: Learn to code with Python. The section links point to the parts of the book it draws on.