The box is a generic container for any widgets, boxes leverage the layout model from the BeeWare Colosseum package.


A box can be instantiated with no children and then the children added later

import toga

box = toga.Box('box1')

button = toga.Button('Hello world', on_press=button_handler)

To create boxes within boxes, use the children argument.

import toga

box_a = toga.Box('box_a')
box_b = toga.Box('box_b)

box = toga.Box('box', children=[box_a, box_b])

Box Styling

Styling of boxes through colosseum can be done pre instantiation or post,

import toga

box = toga.Box('box1')'column', padding_top=10)
import toga
from colosseum import CSS

style = CSS(padding_top=10)
box = toga.Box('box', style=style)

Supported Platforms

Component iOS win32 web django cocoa gtk android
Box yes no no yes yes yes yes


class, style=None, children=None)

This is a Widget that contains other widgets, but has no rendering or interaction of its own.

  • id (str) – An identifier for this widget.
  • style (colosseum.CSSNode) – an optional style object. If no style is provided then a new one will be created for the widget.
  • children (list) – An optional list of child Widgets that will be in this box.

Add a widget as a child of this one.

Raises an ValueError if this widget is a leaf, and cannot have children.

Parameters:child (toga.Widget) – The child to add to the widget

The App to which this widget belongs.

Return type:toga.App

The children of this node.

This always returns a list, even if the node is a leaf and cannot have children.

Return type:list
Returns:A list of the children for this widget

Hide the widget from the super view.


The node identifier. This id can be used to target CSS directives

Return type:str

The parent of this node.

Return type:toga.Widget

Set a font on this widget.

Parameters:font (toga.Font) – The new font

Show the widget on the super view.


The style object for this widget.

Returns:The style for this widget
Return type:colosseum.CSSNode

The Window to which this widget belongs.

Return type:toga.Window