Option Container

The Option Container widget is a user-selection control for choosing from a pre-configured list of controls, like a tab view.

../../_images/OptionContainer.jpeg

Usage

import toga

container = toga.OptionContainer()

table = toga.Table(['Hello', 'World'])
tree = toga.Tree(['Navigate'])

container.add('Table', table)
container.add('Tree', tree)

Supported Platforms

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

Reference

class toga.interface.widgets.optioncontainer.OptionContainer(id=None, style=None, content=None)

Instantiate a new instance of the option container widget

Parameters:
  • 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.
  • content (list of tuple (str, toga.Widget)) – List of components to choose from.
add(label, widget)

Add a widget to the option container

Parameters:
  • label (str) – The label for the option
  • widget (toga.Widget) – The widget to add
app

The App to which this widget belongs.

Return type:toga.App
children

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()

Hide the widget from the super view.

id

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

Return type:str
parent

The parent of this node.

Return type:toga.Widget
set_font(font)

Set a font on this widget.

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

Show the widget on the super view.

style

The style object for this widget.

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

The Window to which this widget belongs.

Return type:toga.Window