Struct gtk::Box []

pub struct Box(_, _);

The Box widget organizes child widgets into a rectangular area.

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

Box uses a notion of packing. Packing refers to adding widgets with reference to a particular position in a Container. For a Box, 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 BoxExt::pack_start to pack widgets into a Box from start to end. Use BoxExt::pack_end to add widgets from end to start. You may intersperse these calls and add widgets from both ends of the same Box.

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

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

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

Use BoxExt::reorder_child to move a Box child to a different place in the box.

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

Note that a single-row or single-column Grid provides exactly the same functionality as Box.

CSS nodes

Box uses a single CSS node with name box.

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


BoxExt, ContainerExt, WidgetExt, glib::object::ObjectExt, BuildableExt, OrientableExt


impl Box


Creates a new Box.


the box’s orientation.


the number of pixels to place by default between children.


a new Box.

Trait Implementations

impl IsA<Box> for AppChooserWidget

impl Clone for Box

Returns a copy of the value. Read more


Performs copy-assignment from source. Read more

impl Debug for Box

Formats the value using the given formatter. Read more

impl Hash for Box

Feeds this value into the given [Hasher]. Read more


Feeds a slice of this type into the given [Hasher]. Read more

impl StaticType for Box

Returns the type identifier of Self.

impl<T: IsA<Object>> PartialEq<T> for Box

This method tests for self and other values to be equal, and is used by ==. Read more


This method tests for !=.

impl Eq for Box

impl IsA<Container> for Box

impl IsA<Widget> for Box

impl IsA<Buildable> for Box

impl IsA<Orientable> for Box

impl IsA<Object> for Box

impl IsA<Box> for ButtonBox

impl IsA<Box> for ColorChooserWidget

impl IsA<Box> for FileChooserButton

impl IsA<Box> for FileChooserWidget

impl IsA<Box> for FontChooserWidget

impl IsA<Box> for InfoBar

impl IsA<Box> for RecentChooserWidget

impl IsA<Box> for StackSwitcher

impl IsA<Box> for Statusbar