liveBook · Manning

Tkinter

As explained in Python Concurrency with asyncio

Tkinter is Python's standard interface to the Tcl/Tk toolkit for building graphical user interfaces.

Tkinter is Python’s standard, platform-independent interface to the Tcl/Tk toolkit for building desktop graphical user interfaces. Its widgets—such as labels, text boxes, and buttons—respond to user actions by calling Python functions. section 7.4.1

A Tkinter application runs inside its own event loop. Calling window.mainloop() keeps redrawing the window and processing widget events, so long-running work inside a callback freezes the interface until that work finishes. section 7.4.1 section 7.4

A button-driven window

Create a window, configure its title and size, place a ttk.Button, connect the button to say_hello, and start the application with window.mainloop(). Clicking the button prints “Hello there!”; adding time.sleep(10) to the callback demonstrates why blocking work is dangerous.

Responsive applications keep the Tkinter event loop in the main thread and run an asyncio event loop in a separate thread. User actions can submit coroutines without blocking, while progress updates travel back to the interface; thread communication still requires care around race conditions and thread safety. section 7.4.2 section 7.6

How Python Concurrency with asyncio covers it

How deep it goes
Explains widgets, callbacks, mainloop(), blocking freezes, and a threaded asyncio architecture without descending into Tk implementation internals.
Examples
Uses a hello-world button application and a URL stress-testing interface with inputs, cancellation, and a progress bar.
What you can do after
Build it from scratch with widgets and callbacks, then operate a responsive UI alongside asyncio work in another thread.
How it connects
Connects GUI event loops with asyncio, threads, callbacks, race conditions, and thread-safe coroutine submission.

Also explained in

Compare how 3 books explain tkinter →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Python Concurrency with asyncio. The section links point to the parts of the book it draws on.