Skip to Main Content
Programming Python, 3rd Edition
book

Programming Python, 3rd Edition

by Mark Lutz
August 2006
Intermediate to advanced content levelIntermediate to advanced
1600 pages
51h 46m
English
O'Reilly Media, Inc.
Content preview from Programming Python, 3rd Edition

“Building a Better Mouse Trap”

This chapter continues our look at building GUIs with Python and the Tkinter library by presenting a collection of more advanced GUI programming patterns and techniques. In the last three chapters, we explored all the fundamentals of Tkinter itself. Here, our goal is to put them to work to add higher-level structures that will be useful in larger programs. Some of the techniques we will be studying in this chapter are as follows:

  • Providing common GUI operations in “mixin” classes

  • Building menus and toolbars from data structure templates

  • Adding GUI interfaces to command-line tools

  • Redirecting input and output streams to GUI widgets

  • Reloading GUI callback handlers on the fly

  • Wrapping up top-level window interfaces

  • Using threads and queues to avoiding blocking in GUIs

  • Popping up GUI windows on demand from non-GUI programs

  • Adding GUIs as separate programs with sockets and pipes

As with other chapters in this book, this chapter has a dual agenda—not only will we be studying GUI programming, but we’ll also be learning more about general Python development concepts such as object-oriented programming (OOP) and code reuse. As we’ll see, by coding GUI tools in Python, it’s easy to apply them in a wide variety of contexts and programs.

Two notes before we begin: first, be sure to read the code listings in this chapter for details we won’t present in the narrative. Second, although small examples that apply in this chapter’s techniques will show up along the way, more realistic ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Python, 3rd Edition

Learning Python, 3rd Edition

Mark Lutz

Publisher Resources

ISBN: 0596009259Supplemental ContentErrata Page