Section 8.12. The End of the Tutorial

8.12. The End of the Tutorial

In this chapter, we learned the core concepts of Python/Tkinter programming and met a handful of simple widget objects along the waye.g., labels, buttons, frames, and the packer geometry manager. We've seen enough to construct simple interfaces, but we have really only scratched the surface of the Tkinter widget set.

In the next two chapters, we will apply what we've learned here to study the rest of the Tkinter library, and we'll learn how to use it to generate the kinds of interfaces you expect to see in realistic GUI programs. As a preview and roadmap, Table 8-1 lists the kinds of widgets we'll meet there in roughly their order of appearance. Note that this table lists only widget classes; along the way, we will also meet a few additional widget-related topics that don't appear in this table.

Table 8-1. Tkinter widget classes

Widget class



A simple message area


A simple labeled push-button widget


A container for attaching and arranging other widget objects

Toplevel, Tk

A new window managed by the window manager


A multiline label


A simple single-line text-entry field


A two-state button widget, typically used for multiple-choice selections


A two-state button widget, typically used for single-choice selections


A slider widget with scalable positions


An image object used for displaying full-color images on other widgets


An image object used for displaying bitmap images on other widgets


A set of options associated with a Menubutton or top-level window


A button that opens a Menu of selectable options and submenus


A control for scrolling other widgets (e.g., listbox, canvas, text)


A list of selection names


A multiline text browse/edit widget, with support for fonts, and so on


A graphic drawing area, which supports lines, circles, photos, text, and so on

We've already met the Label, Button, and Frame in this chapter's tutorial. To make the remaining topics easier to absorb, they are split over the next two chapters: Chapter 9 covers the first widgets in this table up to but not including Menu, and Chapter 10 presents widgets that are lower in this table.

Besides the widget classes in this table, there are additional classes and tools in the Tkinter library, many of which we'll explore in the following two chapters as well:

Geometry management

pack, grid, place

Tkinter linked variables

StringVar, IntVar, DoubleVar, BooleanVar

Advanced Tk widgets

Spinbox, LabelFrame, PanedWindow

Composite widgets

Dialog, ScrolledText, OptionMenu

Scheduled callbacks

Widget after, wait, and update methods

Other tools

Standard dialogs, clipboard, bind and Event, widget configuration options, custom and modal dialogs, animation techniques

Most Tkinter widgets are familiar user interface devices. Some are remarkably rich in functionality. For instance, the Text class implements a sophisticated multiline text widget that supports fonts, colors, and special effects and is powerful enough to implement a web browser's page display, and the Canvas class provides extensive drawing tools powerful enough for visualization and other image processing applications. Beyond this, Tkinter extensions such as the Pmw and Tix packages described at the start of this chapter add even richer widgets to a GUI programmer's toolbox.

Programming Python
Programming Python
ISBN: 0596009259
EAN: 2147483647
Year: 2004
Pages: 270
Authors: Mark Lutz

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: