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

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=VERTICAL, 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
ofWidget
) – The list of components to be split or tuples of components to be split and adjusting parameters in the following order: widget (Widget
): The widget that will be added. weight (float): Specifying the weighted splits. flex (boolean): Should the content expand when the widget is resized. (optional)
Create a base Toga widget.
This is an abstract base class; it cannot be instantiated.
- Parameters:
id – The ID for the widget.
style – A style object. If no style is provided, a default style will be applied to the widget.
- HORIZONTAL = False#
- VERTICAL = True#
- property app#
The App to which this widget belongs.
When setting the app for a widget, all children of this widget will be recursively assigned to the same app.
Raises
ValueError
if the widget is already associated with another app.
- property content#
The sub layouts of the SplitContainer.
- Returns:
A
list
ofWidget
. Each element of the list is a sub layout of the SplitContainer- Raises:
ValueError – If the list is less than two elements long.
- property direction#
The direction of the split.
- Returns:
True if True for vertical, False for horizontal.
- refresh_sublayouts()#
Refresh the layout and appearance of this widget.
- property window#
The window to which this widget belongs.
When setting the window for a widget, all children of this widget will be recursively assigned to the same window.