ScrollContainer¶
A container that can display a layout larger than its own area.







Not supported
Usage¶
import toga
content = toga.Box(children=[...])
container = toga.ScrollContainer(content=content)
Reference¶
toga.ScrollContainer
¶
ScrollContainer(
id: str | None = None,
style: StyleT | None = None,
horizontal: bool = True,
vertical: bool = True,
on_scroll: OnScrollHandler | None = None,
content: Widget | None = None,
**kwargs,
)
Bases: Widget
Create a new Scroll Container.
| PARAMETER | DESCRIPTION |
|---|---|
id
|
The ID for the widget.
TYPE:
|
style
|
A style object. If no style is provided, a default style will be applied to the widget.
TYPE:
|
horizontal
|
Should horizontal scrolling be permitted?
TYPE:
|
vertical
|
Should vertical scrolling be permitted?
TYPE:
|
on_scroll
|
Initial
TYPE:
|
content
|
The content to display in the scroll window.
TYPE:
|
kwargs
|
Initial style properties.
DEFAULT:
|
content
property
writable
¶
content: Widget | None
The root content widget displayed inside the scroll container.
enabled
property
writable
¶
enabled: Literal[True]
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_position
property
writable
¶
horizontal_position: int
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: int
The maximum horizontal scroll position (read-only).
max_vertical_position
property
¶
max_vertical_position: int
The maximum vertical scroll position (read-only).
on_scroll
property
writable
¶
on_scroll: OnScrollHandler
Handler to invoke when the user moves a scroll bar.
position
property
writable
¶
position: 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_position
property
writable
¶
vertical_position: int
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. |
toga.widgets.scrollcontainer.OnScrollHandler
¶
Bases: Protocol
__call__
¶
__call__(widget: ScrollContainer, **kwargs: Any) -> None
A handler to invoke when the container is scrolled.
| PARAMETER | DESCRIPTION |
|---|---|
widget
|
The ScrollContainer that was scrolled.
TYPE:
|
kwargs
|
Ensures compatibility with arguments added in future versions.
TYPE:
|