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.
Actually, I just try various methods to display correctly a table in the wiki.
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.
First style :
------------------------------------------------------------------------------------------------------------------------ | What do you want to do | pack command | grid command | place command | |------------------------------------|--------------------------|--------------------------|---------------------------| | Display 2 widgets side by side | pack $w1 $w2 -side left | grid $w1 $w2 | To be done | |------------------------------------|--------------------------|--------------------------|---------------------------| | Display 2 widgets on top of | pack $w1 $w2 -side top | grid $w1 | To be done | | each other | | grid $w2 | | ------------------------------------------------------------------------------------------------------------------------
Second style :
------------------------------------------------------------------------------------------------------------------------ | Display 2 widgets side by side: | | pack command | grid command | place command | |---------------------------------------|--------------------------------------|---------------------------------------| | pack $w1 $w2 -side left | grid $w1 $w2 | To be done | |----------------------------------------------------------------------------------------------------------------------| | Display 2 widgets on top of each other: | | pack command | grid command | place command | |---------------------------------------|--------------------------------------|---------------------------------------| | pack $w1 $w2 -side top | grid $w1 | To be done | | | grid $w2 | | '----------------------------------------------------------------------------------------------------------------------'
Third style :
|================|=====================================================================================================| | You want to | Display 2 widgets side by side: | |----------------|-----------------------------------------------------------------------------------------------------| | With pack | pack $w1 $w2 -side left | |----------------|-----------------------------------------------------------------------------------------------------| | With grid | grid $w1 $w2 | |----------------|-----------------------------------------------------------------------------------------------------| | With place | To be done. | |================|=====================================================================================================| | 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 | To be done. | |================|=====================================================================================================|
Fourth style :
You want to: Display 2 widgets side by side
You want to: Display 2 widgets on top of each other
Fifth style:
Displaying 2 widgets side-by-side
With pack:
pack $w1 $w2 -side left
With grid:
grid $w1 $w2
With place (well, sort of as you still need to set the container size):
place $w1 -relx 0 -y 0 -relwidth .5 -relheight 1 place $w2 -relx .5 -y 0 -relwidth .5 -relheight 1
Displaying 2 widgets one-over-the-other
With pack:
pack $w1 $w2 -side top
With grid:
grid $w1 grid $w2
With place (well, sort of as you still need to set the container size):
place $w1 -rely 0 -x 0 -relwidth 1 -relheight .5 place $w2 -rely .5 -x 0 -relwidth 1 -relheight .5
Other styles and ideas will be welcome.