PyGTK For GUI Programming/Packing

From Wikibooks, open books for an open world
< PyGTK For GUI Programming
Jump to: navigation, search

Packing is used to place the widgets in the application.

There are three types of packing.

Horizontal Box (HBox) - Horizontal row structure
Vertical Box (VBox) - Vertical row structure
Table/Grid (Table) - Table like structure

To place the widget inside the packing :

1. Create the packing object

hbox = gtk.HBox()

2. Add the widget to the box call the pack_start or pack_end method of the packing object

box.pack_start(widget, expand, fill, padding)

pack_start will start placing the widget from the start (left to right, top to bottom)
pack_end will start placing the widget from the end (right to left, bottom to top)

3. Show the box and widget

The format of the packing widgets is :

hbox = gtk.HBox(homogeneous, spacing)
vbox = gtk.VBox(homogeneous, spacing)
table = gtk.Table(rows, columns, homogeneous)

PyGTK For GUI Programming
 ← Input Widgets Packing