< BACKMake Note | BookmarkCONTINUE >
152015024128143245168232148039199167010047123209178152124239215162149150217129135121220044

Summary

Tk is a popular and endorsed toolkit that can handle windows, GUI events, and user interactions. Tkinter is Python's cross-platform interface to the Tk GUI toolkit that enables you to handle buttons and windows, and define their properties at a glance. The typical Tkinter distribution contains a basic set of 15 widgets, and some extra classes that can be used by your GUI applications.

Button—This widget defines a clickable button that can execute a specific operation when clicked.

Canvas—This widget is used to draw graphs, lines, polygons, and all other types of graphic elements.

Checkbutton—This widget exposes a button that controls a variable that can have two distinct values.

Entry—This widget implements a simple text entry field.

Frame—This widget works like a container for other widgets when creating a complex layout within a window.

Label—This widget handles the exhibition of a text or an image.

Listbox—This widget displays a list of possible selections.

Menu—This widget is used to implement pull-down and pop-up menus.

Menubutton—This widget is used to implement pull-down menus.

Message—This widget displays a text message in a way similar to the label widget, but using powerful formatting capabilities.

Radiobutton—This widget is associated with a variable, and when clicked, the variable assumes its value.

Scale—This widget provides a slider that helps you set the value of a numerical variable.

Scrollbar—This widget implements standard scrollbars that you can use along with other widgets, such as listbox, canvas, entry, and text.

Text—This widget display text that you can edit and format.

Toplevel—This widget is another container widget, just like the frame widget.

Tkinter also provides the Image class. This class is used as a foundation to display graphic objects, including bitmaps and GIF images. Two subclasses are inherited from this class: BitmapImage and PhotoImage.

All these Tkinter widgets have access to specific geometry management methods, which have the purpose of organizing them throughout the parent widget area. These methods are grouped in three distinct classes that provide a nice way to lay out child widgets in their parent widget. Tkinter exposes the following geometry manager classes: pack, grid, and place.

Tkinter also allows you to create event bindings for every specific object, and after binding an event to a widget, you can specify which function should be called at the time the event occurs. This function (or method) is called callback.

To complement Tkinter, you can also use the Python Mega Widgets. PMW is a toolkit for building high-level widgets in Python using the Tkinter module that provides many interesting and complex widgets.


Last updated on 1/30/2002
Python Developer's Handbook, © 2002 Sams Publishing

< BACKMake Note | BookmarkCONTINUE >

© 2002, O'Reilly & Associates, Inc.