Gtk.Box

const Gtk = imports.gi.Gtk;

let box = new Gtk.Box({
    homogeneous: value,
    spacing: value,
});
  

The GtkBox widget organizes child widgets into a rectangular area.

The rectangular area of a GtkBox is organized into either a single row or a single column of child widgets depending upon the orientation. Thus, all children of a GtkBox are allocated one dimension in common, which is the height of a row, or the width of a column.

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

Use repeated calls to Gtk.pack_start to pack widgets into a GtkBox from start to end. Use Gtk.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 Gtk.Container, you may also use Gtk.add to insert widgets into the box, and they will be packed with the default values for #GtkBox:expand and #GtkBox:fill. Use Gtk.remove to remove widgets from the GtkBox.

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

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

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

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

<note><para> Note that a single-row or single-column Gtk.Grid provides exactly the same functionality as Gtk.Box. </para></note>

Hierarchy

  • GObject.Object
    • GObject.InitiallyUnowned
      • Gtk.Widget
        • Gtk.Container
          • Gtk.Box