Scroll Container#

Availability (Key)#

macOS

GTK

Windows

iOS

Android

Web

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, on_scroll=None, 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 (Widget) – The content of the scroll window.

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.

MIN_HEIGHT = 100#
MIN_WIDTH = 100#
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#

Content of the scroll container.

Returns:

The content of the widget (Widget).

property horizontal#

Shows whether horizontal scrolling is enabled.

Returns:

(bool) True if enabled, False if disabled.

property horizontal_position#
property on_scroll#
refresh_sublayouts()#

Refresh the layout and appearance of this widget.

property vertical#

Shows whether vertical scrolling is enabled.

Returns:

(bool) True if enabled, False if disabled.

property vertical_position#
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.