O'Reilly logo

Web, Graphics & Perl/Tk Programming by Jon Orwant

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 38. The Pack and Grid Geometry Managers

Steve Lidie

We know that every Perl/Tk graphical application consists of a number of widgets arranged in a particular manner on a display. Although we may suggest the size and location of the widgets, the final say in the matter is up to a geometry manager, the software responsible for computing the actual layout of the widgets.

In essence, a geometry manager’s job is to stuff what are known as, in X parlance, slave widgets inside a master widget. The topmost master widget in a Perl/Tk application is of course the MainWindow. In the simplest case it’s the only master, but usually we need to employ one or more frames within which more slaves are packed. Once the slaves in these frames have been arranged, the frames themselves are laid out within the MainWindow.

This means that in order to calculate the final look of an application, geometry information propagates outwards from the innermost masters to the MainWindow. We’ll see why and how to override this behavior later.

Before any widget can appear on the display, it must be managed by a geometry manager. There can actually be multiple geometry managers controlling an application, although this is unusual, and a widget can only be managed by one geometry manager at a time.

The Perl/Tk distribution contains various geometry managers, including place, pack, and grid, and in this article we’ll discuss the “packer” and the “gridder.” As its name suggests, the grid geometry manager places widgets ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required