Skip to content

textual.screen

This module contains the Screen class and related objects.

The Screen class is a special widget which represents the content in the terminal. See Screens for details.

ScreenResultCallbackType module-attribute

ScreenResultCallbackType = Union[
    Callable[[Optional[ScreenResultType]], None],
    Callable[[Optional[ScreenResultType]], Awaitable[None]],
]

Type of a screen result callback function.

ScreenResultType module-attribute

ScreenResultType = TypeVar('ScreenResultType')

The result type of a screen.

HoverWidgets

Bases: NamedTuple

Result of [get_hover_widget_at][textual.screen.Screen.get_hover_widget_at]

hover_over instance-attribute

hover_over

Widget with a hover style under the mouse, or None for no hover style widget.

mouse_over instance-attribute

mouse_over

Widget and region directly under the mouse.

widgets property

widgets

Just the widgets.

ModalScreen

ModalScreen(name=None, id=None, classes=None)

Bases: Screen[ScreenResultType]

A screen with bindings that take precedence over the App's key bindings.

The default styling of a modal screen will dim the screen underneath.

ResultCallback

ResultCallback(requester, callback, future=None)

Bases: Generic[ScreenResultType]

Holds the details of a callback.

Parameters:

Name Type Description Default

requester

MessagePump

The object making a request for the callback.

required

callback

ScreenResultCallbackType[ScreenResultType] | None

The callback function.

required

future

Future[ScreenResultType] | None

A Future to hold the result.

None

callback instance-attribute

callback = callback

The callback function.

future instance-attribute

future = future

A future for the result

requester instance-attribute

requester = requester

The object in the DOM that requested the callback.

Screen

Screen(name=None, id=None, classes=None)

Bases: Generic[ScreenResultType], Widget

The base class for screens.

Parameters:

Name Type Description Default

name

str | None

The name of the screen.

None

id

str | None

The ID of the screen in the DOM.

None

classes

str | None

The CSS classes for the screen.

None

ALLOW_IN_MAXIMIZED_VIEW class-attribute

ALLOW_IN_MAXIMIZED_VIEW = None

A selector for the widgets (direct children of Screen) that are allowed in the maximized view (in addition to maximized widget). Or None to default to App.ALLOW_IN_MAXIMIZED_VIEW

AUTO_FOCUS class-attribute