Skip to content

textual.scroll_view

ScrollView is a base class for Line API widgets.

ScrollView

ScrollView(
    *children,
    name=None,
    id=None,
    classes=None,
    disabled=False,
    can_focus=None,
    can_focus_children=None,
    can_maximize=None,
)

Bases: ScrollableContainer

A base class for a Widget that handles its own scrolling (i.e. doesn't rely on the compositor to render children).

name: The name of the widget.
id: The ID of the widget in the DOM.
classes: The CSS classes for the widget.
disabled: Whether the widget is disabled or not.
can_focus: Can this container be focused?
can_focus_children: Can this container's children be focused?
can_maximized: Allow this container to maximize? `None` to use default logic.,

is_scrollable property

is_scrollable

Always scrollable.

refresh_line

refresh_line(y)

Refresh a single line.

Parameters:

Name Type Description Default

y

int

Coordinate of line.

required

refresh_lines

refresh_lines(y_start, line_count=1)

Refresh one or more lines.

Parameters:

Name Type Description Default

y_start

int

First line to refresh.

required

line_count

int

Total number of lines to refresh.

1

scroll_to

scroll_to(
    x=None,
    y=None,
    *,
    animate=True,
    speed=None,
    duration=None,
    easing=None,
    force=False,
    on_complete=None,
    level="basic",
    immediate=False
)

Scroll to a given (absolute) coordinate, optionally animating.

Parameters:

Name Type Description Default

x

float | None

X coordinate (column) to scroll to, or None for no change.

None

y

float | None

Y coordinate (row) to scroll to, or None for no change.

None

animate

bool

Animate to new scroll position.

True

speed

float | None

Speed of scroll if animate is True; or None to use duration.

None

duration

float | None

Duration of animation, if animate is True and speed is None.

None

easing

EasingFunction | str | None

An easing method for the scrolling animation.

None

force

bool

Force scrolling even when prohibited by overflow styling.

False

on_complete

CallbackType | None

A callable to invoke when the animation is finished.

None

level

AnimationLevel

Minimum level required for the animation to take place (inclusive).

'basic'

immediate

bool

If False the scroll will be deferred until after a screen refresh, set to True to scroll immediately.

False