Scroll Container

macOS GTK+ Windows iOS Android Django
y y y y    

The Scroll Container is similar to the iframe or scrollable div element in HTML, it contains an object with its own scrollable selection.

../../../_images/ScrollContainer.jpeg

Usage

import toga

content = toga.WebView()

container = toga.ScrollContainer(content=content)

Scroll settings

Horizontal or vertical scroll can be set via the initializer or using the property.

import toga

content = toga.WebView()

container = toga.ScrollContainer(content=content, horizontal=False)

container.vertical = False

Reference

class toga.widgets.scrollcontainer.ScrollContainer(id=None, style=None, horizontal=True, vertical=True, content=None, factory=None)

Instantiate a new instance of the scrollable container widget.

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.
  • horizontal (bool) – If True enable horizontal scroll bar.
  • vertical (bool) – If True enable vertical scroll bar.
  • content (toga.Widget) – The content of the scroll window.
  • ( (factory) – module:): A provided factory module will be used to create the implementation of the ScrollContainer.
MIN_HEIGHT = 100
MIN_WIDTH = 100
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

Content of the scroll container.

Returns:The content of the widget (toga.Widget).
enabled
horizontal

Shows whether horizontal scrolling is enabled.

Returns:(bool) True if enabled, False if disabled.
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 this widget.

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.
vertical

Shows whether vertical scrolling is enabled.

Returns:(bool) True if enabled, False if disabled.
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.