Split Container

macOS GTK+ Windows iOS Android Django
y y y      

The split container is a container with a movable split and the option for 2 or 3 elements.

../../../_images/SplitContainer.jpeg

Usage

import toga

split = toga.SplitContainer()
left_container = toga.Box()
right_container = toga.ScrollContainer()

split.content = [left_container, right_container]

Setting split direction

Split direction is set on instantiation using the direction keyword argument. Direction is vertical by default.

import toga

split = toga.SplitContainer(direction=toga.SplitContainer.HORIZONTAL)
left_container = toga.Box()
right_container = toga.ScrollContainer()

split.content = [left_container, right_container]

Reference

class toga.widgets.splitcontainer.SplitContainer(id=None, style=None, direction=True, content=None, factory=None)

A SplitContainer displays two widgets vertically or horizontally next to each other with a movable divider.

Parameters:
  • id (str) – An identifier for this widget.
  • style (Style) – An optional style object. If no style is provided then a new one will be created for the widget.
  • direction – The direction for the container split, either SplitContainer.HORIZONTAL or SplitContainer.VERTICAL
  • content (list of toga.Widget) – The list of components to be split.
  • factory (module) – A python module that is capable to return a implementation of this class with the same name. (optional & normally not needed)
HORIZONTAL = False
VERTICAL = True
add(*children)

Add a node as a child of this one. :param child: A node to add as a child to this node.

Raises:ValueError – If this node is a leaf, and cannot have children.
app

The App to which this widget belongs. On setting the app we also iterate over all children of this widget and set them to the same app.

Returns:The toga.App to which this widget belongs.
Raises:ValueError – If the widget is already associated with another app.
can_have_children

Determine if the node can have children.

This does not resolve whether there actually are any children; it only confirms whether children are theoretically allowed.

children

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

Returns:A list of the children for this widget.
content

The sub layouts of the SplitContainer.

Returns:A list of toga.Widget. Each element of the list is a sub layout of the SplitContainer
Raises:ValueError – If the list is less than two elements long.
direction

The direction of the split

Returns:True if True for vertical, False for horizontal.
enabled
id

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

Returns:The widgets identifier as a str.
parent

The parent of this node.

Returns:The parent of this node. Returns None if this node is the root node.
refresh()

Refresh the layout and appearance of the tree this node is contained in.

refresh_sublayouts()

Refresh the layout and appearance of this widget.

root

The root of the tree containing this node.

Returns:The root node. Returns self if this node is the root node.
window

The Window to which this widget belongs. On setting the window, we automatically update all children of this widget to belong to the same window.

Returns:The toga.Window to which the widget belongs.