gtk.Box
Prev | The gtk Class Reference | Next

## gtk.Box

gtk.Box — an abstract base class for box containers

## Synopsis

    class gtk.Box(gtk.Container):
        def pack_start(child, expand=TRUE, fill=TRUE, padding=0)
        def pack_end(child, expand=TRUE, fill=TRUE, padding=0)
        def pack_start_defaults(widget)
        def pack_end_defaults(widget)
        def set_homogeneous(homogeneous)
        def get_homogeneous()
        def set_spacing(spacing)
        def get_spacing()
        def reorder_child(child, position)
        def query_child_packing(child)
        def set_child_packing(child, expand, fill, padding, pack_type)

## Ancestry

    +-- gobject.GObject
      +-- gtk.Object
        +-- gtk.Widget
          +-- gtk.Container
            +-- gtk.Box

## gtk.Box Properties

gtk.Object Properties

gtk.Widget Properties

gtk.Container Properties

"spacing" | Read/Write | The amount of space between children.
"homogeneous" | Read/Write | If TRUE the children should all be the same size.
"spacing" | Read/Write | The amount of space between children.

## gtk.Box Style Properties

gtk.Widget Style Properties

## gtk.Box Child Properties

"expand" | Read/Write | If `TRUE` the child should receive extra space when the parent grows
"fill" | Read/Write | If `TRUE` extra space given to the child should be allocated to the child; if `FALSE` extra space given to the child should be used as padding
"padding" | Read/Write | The amount of extra space to put between the child and its neighbors, in pixels
"pack-type" | Read/Write | Indicates whether the child is packed with reference to the start (`gtk.PACK_START`) or end (`gtk.PACK_END`) of the parent
"position" | Read/Write | The index of the child in the parent

## gtk.Box Signal Prototypes

gobject.GObject Signal Prototypes

gtk.Object Signal Prototypes

gtk.Widget Signal Prototypes

gtk.Container Signal Prototypes

## Description

The `gtk.Box` class is an abstract base class defining a widget that encapsulates functionality for a particular kind of container, one that organizes a variable number of widgets into a rectangular area. `gtk.Box` currently has two derived classes, `gtk.HBox` and `gtk.VBox`.

The rectangular area of a `gtk.Box` is organized into either a single row or a single column of child widgets depending upon whether the box is of type `gtk.HBox` or `gtk.VBox`, respectively. Thus, all children of a `gtk.Box` are allocated one dimension in common, which is the height of a row, or the width of a column.

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

Repeated calls to `pack_start`() pack widgets into a `gtk.Box` from start to end. The `pack_end`() method adds widgets from end to start. You may intersperse these calls and add widgets from both ends of the same `gtk.Box`.

Because `gtk.Box` is a `gtk.Container`, you may also use `add`() to insert widgets into the box, and they will be packed as if with the `pack_start`() method. Use `remove`() to remove widgets from the `gtk.Box`.

The `set_homogeneous`() method specifies whether or not all children of the `gtk.Box` are forced to get the same amount of space.

The `set_spacing`() method determines how much space will be minimally placed between all children in the `gtk.Box`.

The `reorder_child`() method moves a `gtk.Box` child to a different place in the box.

The `set_child_packing`() method resets the expand, fill, and padding attributes of any `gtk.Box` child. Use the `query_child_packing`() to query these properties.

## Methods

### gtk.Box.pack_start

        def pack_start(child, expand=TRUE, fill=TRUE, padding=0)

`child` : | the widget to be added to the box
`expand` : | TRUE if `child` is to be given extra space allocated to box. The extra space will be divided evenly between all children of box that use this option.
`fill` : | TRUE if space given to `child` by the `expand` option is actually allocated to `child`, rather than just padding it. This parameter has no effect if `expand` is set to FALSE. A child is always allocated the full height of a `gtk.HBox` and the full width of a `gtk.VBox`. This option affects the other dimension.
`padding` : | extra space in pixels to put between `child` and its neighbors, over and above the global amount specified by `spacing` in `gtk.Box`. If `child` is a widget at one of the reference ends of box, then `padding` pixels are also put between `child` and the reference edge of box.

The `pack_start`() method adds `child` to the box, packed with reference to the start of box. The `child` is packed after any other child packed with reference to the start of box.

### gtk.Box.pack_end

        def pack_end(child, expand=TRUE, fill=TRUE, padding=0)

`child` : | the widget to be added to the box
`expand` : | TRUE if `child` is to be given extra space allocated to box. The extra space will be divided evenly between all children of box that use this option.
`fill` : | TRUE if space given to `child` by the `expand` option is actually allocated to `child`, rather than just padding it. This parameter has no effect if `expand` is set to FALSE. A child is always allocated the full height of a `gtk.HBox` and the full width of a `gtk.VBox`. This option affects the other dimension.
`padding` : | extra space in pixels to put between `child` and its neighbors, over and above the global amount specified by `spacing` in `gtk.Box`. If `child` is a widget at one of the reference ends of box, then `padding` pixels are also put between `child` and the reference edge of box.

The `pack_end`() method adds `child` to the box, packed with reference to the end of the box. The `child` is packed after (away from end of) any other child packed with reference to the end of the box.

### gtk.Box.pack_start_defaults

        def pack_start_defaults(widget)

`widget` : | the widget to be added to the box

### Warning

This method is deprecated in PyGTK 2.4 and above.

The `pack_start_defaults`() method adds `widget` to the box, packed with reference to the start of the box. The `widget` is packed after any other child widget packed with reference to the start of box. The parameters for packing the child widget: expand, fill, and padding are given their default values, TRUE, TRUE, and 0, respectively.

### gtk.Box.pack_end_defaults

        def pack_end_defaults(widget)

`widget` : | the widget to be added to the box

### Warning

This method is deprecated in PyGTK 2.4 and above.

The `pack_end_defaults`() method adds `widget` to the box, packed with reference to the end of the box. The `widget` is packed after (away from the end of) any other child widget packed with reference to the end of the box. The parameters for packing the child widget: expand, fill, and padding are given their default values, TRUE, TRUE, and 0, respectively.

### gtk.Box.set_homogeneous

        def set_homogeneous(homogeneous)

`homogeneous` : | If `TRUE` the box is homogeneous i.e. all children are allocated the same space otherwise the allocations vary for each child.

The `set_homogeneous`() method sets the homogeneous (all children are allocated the same space) property of the box.

### gtk.Box.get_homogeneous

        def get_homogeneous()

Returns : | `TRUE` if the box is homogeneous.

The `get_homogeneous`() method returns whether the box is homogeneous (all children are allocated the same space). See `gtk.Box.set_homogeneous()`.

### gtk.Box.set_spacing

        def set_spacing(spacing)

`spacing` : | the number of pixels to put between children.

The `set_spacing`() method sets the number of pixels to place between children of the box.

### gtk.Box.get_spacing

        def get_spacing()

Returns : | the spacing in pixels between children

The `get_spacing`() method returns the number of pixels used as padding between children as set by the `set_spacing`().

### gtk.Box.reorder_child

        def reorder_child(child, position)

`child` : | the child widget to move
`position` : | the new position for child in the children list of the box starting from 0. If negative, indicates the end of the list.

Moves child to a new position in the list of the box children. The list contains both widgets packed gtk.PACK_START as well as widgets packed gtk.PACK_END, in the order that these widgets were added to box.

A widget's position in the box children list determines where the widget is packed into box. A child widget at some position in the list will be packed just after all other widgets of the same packing type that appear earlier in the list.

### gtk.Box.query_child_packing

        def query_child_packing(child)

`child` : | the child widget to be queried for its packing information
`expand` : | the child's expand value
`fill` : | the child's fill value
`padding` : | the child's padding value
`pack_type` : | the child's pack_type value

The `query_child_packing`() method returns a tuple containing information about how `child` is packed into the box. The tuple members are: (expand, fill, padding, pack_type) where: expand and fill are 0 or 1 (corresponding to FALSE or TRUE); padding is the number of pixels of padding; and pack_type is gtk.PACK_START or gtk.PACK_END.

### gtk.Box.set_child_packing

        def set_child_packing(child, expand, fill, padding, pack_type)

`child` : | the child widget to be queried for its packing information
`expand` : | the child's new expand value
`fill` : | the child's new fill value
`padding` : | the child's new padding value
`pack_type` : | the child's new pack_type value

The `set_child_packing`() method sets the way child is packed into the box.

Prev | Up | Next
gtk.Border | Home | gtk.Button