Title: Packing Boxes
1Packing Boxes
2Positioning of widgets within a window is
achieved with the use of packing boxes or tables.
To display widgets one on top of another, a
vertical box is used.
To display widgets side by side, a horizontal box
is used.
GtkWidget box box gtk_vbox_new(False, 0)
3Homogeneous - all widgets are assigned the same
width (in a horizontal box), the same height (in
a vertical box).
Spacing - the default (minimum) number of pixels
between child widgets
HOMOGENEOUS
SPACING
GtkWidget box box gtk_vbox_new(False, 0)
4GtkWidget box box gtk_vbox_new(False,
0) gtk_box_pack_start(GTK_BOX(box),
button1, FALSE, FALSE, 0)
5GtkWidget box box gtk_vbox_new(False,
0) gtk_box_pack_start(GTK_BOX(box),
button1, FALSE, FALSE, 0) gtk_box_pack_start(GTK
_BOX(box), button2, FALSE, FALSE, 0)
When gtk_box_pack_start is used in a vbox,
widgets are inserted at the top of the box, any
others added at the top go below.
6GtkWidget box box gtk_vbox_new(False,
0) gtk_box_pack_end(GTK_BOX(box),
button1, FALSE, FALSE, 0) gtk_box_pack_end(GTK_B
OX(box), button2, FALSE, FALSE, 0)
When gtk_box_pack_end is used in a vbox,
widgets are inserted at the bottom of the box,
any others added at the top go above.
7Packing Tables allow placement of widgets in a
window using x and y coordinate values.
GtkWidget table table gtk_table_new(3, 2,
TRUE)
gtk_table_attach_defaults( GTK_TABLE(table),
button, 1,1,0,1)