Combining pack and grid

It is not possible to combine pack and grid within the same container. If you attempt this the geometry managers will both attempt to control the screen geometry resulting in the screen failing to load. If you choose to combine the two, you may use pack to display a container (for example, a frame), which then utilizes the grid command to place the widgets within a grid located within the frame.

How to do it…

In the following example, we will create a frame and load it using the pack command. We will then arrange several widgets using the grid command identical to the previous example whose parent is the frame. Enter the following commands:

 1 % frame .f -borderwidth 3 -relief raised .f 2 % entry .f.e -width 10 .f.e 3 % label ...

Get Tcl/Tk 8.5 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.