Chapter 23. The Pack Geometry Manager

   

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Part III.  Tk Basics


This chapter explores the pack geometry manager that positions widgets on the screen.

Geometry managers arrange widgets on the screen. This chapter describes the pack geometry manager, which is a constraint-based system. The next two chapters describe the grid and place geometry managers. The pack and grid geometry managers are quite general, while place is used for special-purpose applications. This book uses pack a lot because it was the original geometry manager for Tk. The grid geometry manager was added in Tk 4.1.

A geometry manager uses one widget as a parent, and it arranges multiple children (also called slaves) inside the parent. The parent is almost always a frame, but this is not strictly necessary. A widget can only be managed by one geometry manager at a time, but you can use different managers to control different widgets in your user interface. If a widget is not managed, then it doesn't appear on your display at all.

The packer is a powerful constraint-based geometry manager. Instead of specifying in detail the placement of each window, the programmer defines some constraints about how windows should be positioned, and the packer works out the details. It is important to understand the algorithm the packer uses; otherwise, the constraint-based results may not be what you expect.

This chapter explores the packer through a series of examples. The background of the main window is set to black, and the other frames are given different colors so you can identify frames and observe the effect of the different packing parameters. When consecutive examples differ by a small amount, the added command or option is printed in bold courier to highlight the addition.


       
    Top
     



    Practical Programming in Tcl and Tk
    Practical Programming in Tcl and Tk (4th Edition)
    ISBN: 0130385603
    EAN: 2147483647
    Year: 1999
    Pages: 478

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net