Graphical User Interfaces

9.1 Basics of tkinter GUI Development

9.2 Event-Based tkinter Widgets

9.3 Designing GUIs

9.4 OOP for GUIs

9.5 Case Study: Developing a Calculator

Chapter Summary

Solutions to Practice Problems



THIS CHAPTER INTRODUCES graphical user interface (GUI) development.

When you use a computer application—whether it is a web browser, an email client, a computer game, or your Python integrated development environment (IDE)—you typically do so through a GUI, using a mouse and a keyboard. There are two reasons for using a GUI: A GUI gives a better overview of what an application does, and it makes it easier to use the application.

In order to develop GUIs, a developer will require a GUI application programming interface (API) that provides the necessary GUI toolkit. There are several GUI APIs for Python; in this text we use tkinter, a module that is part of Python's Standard Library.

Beyond the development of GUIs using tkinter, this chapter also covers fundamental software development techniques that are naturally used in GUI development. We introduce event-driven programming, an approach for developing applications in which tasks are executed in response to events (such a button clicks). We also learn that GUIs are ideally developed as user-defined classes, and we take the opportunity to once again showcase the benefit of object-oriented programming (OOP).

9.1 Basics of tkinter GUI Development

A graphical user interface (GUI) consists ...

Get Introduction to Computing Using Python: An Application Development Focus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.