Object Hierarchy:

Gtk.Box Gtk.Box Gtk.Box Gtk.Container Gtk.Container Gtk.Container->Gtk.Box Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Container GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Atk.Implementor Atk.Implementor Atk.Implementor->Gtk.Box Atk.Implementor->Gtk.Container Atk.Implementor->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.Box Gtk.Buildable->Gtk.Container Gtk.Buildable->Gtk.Widget Gtk.Orientable Gtk.Orientable Gtk.Orientable->Gtk.Box


[ CCode ( type_id = "gtk_box_get_type ()" ) ]
public class Box : Container, Implementor, Buildable, Orientable

The GtkBox widget arranges child widgets into a single row or column, depending upon the value of its orientation property.

Within the other dimension, all children are allocated the same size. Of course, the halign and valign properties can be used on the children to influence their allocation.

GtkBox uses a notion of packing. Packing refers to adding widgets with reference to a particular position in a Container. For a GtkBox, there are two reference positions: the start and the end of the box. For a vertical Box, the start is defined as the top of the box and the end is defined as the bottom. For a horizontal Box the start is defined as the left side and the end is defined as the right side.

Use repeated calls to pack_start to pack widgets into a GtkBox from start to end. Use pack_end to add widgets from end to start. You may intersperse these calls and add widgets from both ends of the same GtkBox.

Because GtkBox is a Container, you may also use add to insert widgets into the box, and they will be packed with the default values for expand and fill child properties. Use remove to remove widgets from the GtkBox.

Use set_homogeneous to specify whether or not all children of the GtkBox are forced to get the same amount of space.

Use set_spacing to determine how much space will be minimally placed between all children in the GtkBox. Note that spacing is added between the children, while padding added by pack_start or pack_end is added on either side of the widget it belongs to.

Use reorder_child to move a GtkBox child to a different place in the box.

Use set_child_packing to reset the expand, fill and padding child properties. Use query_child_packing to query these fields.

CSS nodes

GtkBox uses a single CSS node with name box.

In horizontal orientation, the nodes of the children are always arranged from left to right. So GtkBox:first-child will always select the leftmost child, regardless of text direction.

Example: Box:

public class Application : Gtk.Window {
public Application () {
// Prepare Gtk.Window:
this.title = "My Gtk.Box";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);
this.set_default_size (350, 70);

// The Box:
Gtk.Box box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
box.pack_start (new Gtk.Label ("1"), false, false, 0);
box.pack_start (new Gtk.Label ("2"), false, false, 0);
box.pack_start (new Gtk.Label ("3"), true, false, 0);
this.add (box);

public static int main (string[] args) {
Gtk.init (ref args);

Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;

valac --pkg gtk+-3.0 Gtk.Box.vala

Namespace: Gtk
Package: gtk+-3.0



Creation methods:


Inherited Members:

All known members inherited from class Gtk.Widget
All known members inherited from interface Atk.Implementor
All known members inherited from interface Gtk.Orientable