Version 37 of Comparing Geometry Managers

Updated 2003-07-02 10:16:44

kroc 1 July 2003 - The idea is to write a table to explain which commands you can use with grid, pack and place for a wanted result. The purpose of this table is not to supply ready to use code but to compare the various existing methods. It can be also used as a syntax reminder.


Initial postulate:

$w1, $w2, ... $wN are simple widgets set like that:

 set w1 [button $container.b1 -text "button 1" -command ...]

place commands assume you've already set the container size.


 |================|=====================================================================================================|
 | You want to    | Display 2 widgets side by side:                                                                     |
 |----------------|-----------------------------------------------------------------------------------------------------|
 | With pack      | pack $w1 $w2 -side left                                                                             |
 |----------------|-----------------------------------------------------------------------------------------------------|
 | With grid      | grid $w1 $w2                                                                                        |
 |----------------|-----------------------------------------------------------------------------------------------------|
 | With place     | place $w1 -relx 0  -y 0 -relwidth .5 -relheight 1                                                   |
 |                | place $w2 -relx .5 -y 0 -relwidth .5 -relheight 1                                                   |
 |================|=====================================================================================================|
 | You want to    | Display 2 widgets on top of each other:                                                             |
 |----------------|-----------------------------------------------------------------------------------------------------|
 | With pack      | pack $w1 $w2 -side top                                                                              |
 |----------------|-----------------------------------------------------------------------------------------------------|
 | With grid      | grid $w1                                                                                            |
 |                | grid $w2                                                                                            |
 |----------------|-----------------------------------------------------------------------------------------------------|
 | With place     | place $w1 -rely 0  -x 0 -relwidth 1 -relheight .5                                                   |
 |                | place $w2 -rely .5 -x 0 -relwidth 1 -relheight .5                                                   |
 |================|=====================================================================================================|

To be continued...