Tkinter is Python’s standard GUI framework, making it convenient for developing graphical user interfaces. As a cross-platform library, Tkinter ensures your applications appear native across Windows, macOS, and Linux. Despite criticisms of its outdated appearance, Tkinter remains a practical choice for quickly creating functional and cross-platform GUI applications.
By the end of this tutorial, you’ll understand that:
- GUI refers to graphical user interfaces, and Tkinter is Python’s built-in library for creating them.
- Tkinter is included with most Python installations, so separate installation is often unnecessary.
- Tkinter is still a relevant choice for building simple, cross-platform GUI applications.
- Widgets in a Tkinter application can be arranged using geometry managers like
.pack(),.place(), and.grid(). - Interactive GUI applications with Tkinter are created by binding events, such as button clicks, to Python functions.
You’ll cover getting started with Tkinter, managing widgets, and creating interactive applications. Once you’ve mastered these skills by working through the exercises at the end of each section, you’ll tie everything together by building two applications. The first is a temperature converter, and the second is a text editor. It’s time to dive right in and learn how to build an application with Tkinter!
Note: This tutorial is adapted from the chapter “Graphical User Interfaces” of Python Basics: A Practical Introduction to Python 3.
The book uses Python’s built-in IDLE editor to create and edit Python files and interact with the Python shell. In this tutorial, references to IDLE have been removed in favor of more general language.
The bulk of the material in this tutorial has been left unchanged, and you should have no problems running the example code from the editor and environment of your choice.