Each line contains one horizontal box (hbox) with several buttons. The call to Pack() is shorthand for the call to pack each of the buttons into the hbox. Each of the buttons is packed into the hbox the same way (i.e., same arguments to the PackStart() method).
This is the declaration of the PackStart() method.
box1.PackStart( Widget child, bool expand, bool fill, int padding);The first argument is object you want to pack into the box. The objects will all be buttons for now, so we'll be packing buttons into boxes.
The expand argument to PackStart() and PackEnd() controls whether the widgets are laid out in the box to fill in all the extra space in the box so the box is expanded to fill the area allotted to it (true); or the box is shrunk to just fit the widgets (false). Setting expand to false will allow you to do right and left justification of your widgets. Otherwise, they will all expand to fit into the box, and the same effect could be achieved by using only one of PackStart() or PackEnd().
The fill argument to the Pack() functions control whether the extra space is allocated to the objects themselves (true), or as extra padding in the box around these objects (false). It only has an effect if the expand argument is also true.
When creating a new box, the function looks like this:
Widget hbox1 = new HBox( bool homogeneous, int spacing );The homogeneous argument to HBox() (and the same for VBox()) controls whether each object in the box has the same size (i.e., the same width in an hbox, or the same height in a vbox). If it is set, the Pack() routines function essentially as if the expand argument was always turned on.
What's the difference between spacing (set when the box is created) and padding (set when elements are packed)? Spacing is added between objects, and padding is added on either side of an object. The following figure should make it clearer: