Skip to content
Toga
0.5.3.dev143+gabcc6cdb6

ScrollContainer

A container that can display a layout larger than the area of the container, with overflow controlled by scroll bars.

/reference/images/scrollcontainer-cocoa.png

/reference/images/scrollcontainer-gtk.png

/reference/images/scrollcontainer-winforms.png

/reference/images/scrollcontainer-android.png

/reference/images/scrollcontainer-iOS.png

/reference/images/scrollcontainer-web.png

Not supported

Usage

import toga

content = toga.Box(children=[...])

container = toga.ScrollContainer(content=content)

Reference

toga.ScrollContainer

ScrollContainer(
    id=None,
    style=None,
    horizontal=True,
    vertical=True,
    on_scroll=None,
    content=None,
    **kwargs,
)

Bases: Widget

Create a new Scroll Container.

PARAMETER DESCRIPTION
id

The ID for the widget.

TYPE: str | None DEFAULT: None

style

A style object. If no style is provided, a default style will be applied to the widget.

TYPE: StyleT | None DEFAULT: None

horizontal

Should horizontal scrolling be permitted?

TYPE: bool DEFAULT: True

vertical

Should vertical scrolling be permitted?

TYPE: bool DEFAULT: True

on_scroll

Initial on_scroll handler.

TYPE: OnScrollHandler | None DEFAULT: None

content

The content to display in the scroll window.

TYPE: Widget | None DEFAULT: None

kwargs

Initial style properties.

DEFAULT: {}

content property writable

content

The root content widget displayed inside the scroll container.

enabled property writable

enabled

Is the widget currently enabled? i.e., can the user interact with the widget?

ScrollContainer widgets cannot be disabled; this property will always return True; any attempt to modify it will be ignored.

horizontal property writable

horizontal

Is horizontal scrolling enabled?

horizontal_position property writable

horizontal_position

The current horizontal scroll position.

If the value provided is negative, or greater than the maximum horizontal position, the value will be clipped to the valid range.

RETURNS DESCRIPTION
int

The current horizontal scroll position.

RAISES DESCRIPTION
ValueError

If an attempt is made to change the horizontal position when horizontal scrolling is disabled.

max_horizontal_position property

max_horizontal_position

The maximum horizontal scroll position (read-only).

max_vertical_position property

max_vertical_position

The maximum vertical scroll position (read-only).

on_scroll property writable

on_scroll

Handler to invoke when the user moves a scroll bar.

position property writable

position

The current scroll position.

If the value provided for either axis is negative, or greater than the maximum position in that axis, the value will be clipped to the valid range.

If scrolling is disabled in either axis, the value provided for that axis will be ignored.

vertical property writable

vertical

Is vertical scrolling enabled?

vertical_position property writable

vertical_position

The current vertical scroll position.

If the value provided is negative, or greater than the maximum vertical position, the value will be clipped to the valid range.

RETURNS DESCRIPTION
int

The current vertical scroll position.

RAISES DESCRIPTION
ValueError

If an attempt is made to change the vertical position when vertical scrolling is disabled.

focus

focus()

No-op; ScrollContainer cannot accept input focus.

toga.widgets.scrollcontainer.OnScrollHandler

Bases: Protocol

__call__

__call__(widget, **kwargs)

A handler to invoke when the container is scrolled.

PARAMETER DESCRIPTION
widget

The ScrollContainer that was scrolled.

TYPE: ScrollContainer

kwargs

Ensures compatibility with arguments added in future versions.

TYPE: Any DEFAULT: {}