Skip to content

textual.app

Here you will find the App class, which is the base class for Textual apps.

See app basics for how to build Textual apps.

AutopilotCallbackType module-attribute

AutopilotCallbackType = (
    "Callable[[Pilot[object]], Coroutine[Any, Any, None]]"
)

Signature for valid callbacks that can be used to control apps.

CommandCallback module-attribute

CommandCallback = (
    "Callable[[], Awaitable[Any]] | Callable[[], Any]"
)

Signature for callbacks used in get_system_commands

RenderResult module-attribute

RenderResult = 'RenderableType | Visual | SupportsVisual'

Result of Widget.render()

ScreenType module-attribute

ScreenType = TypeVar('ScreenType', bound=Screen)

Type var for a Screen, used in get_screen.

ActionError

Bases: Exception

Base class for exceptions relating to actions.

ActiveModeError

Bases: ModeError

Raised when attempting to remove the currently active mode.

App

App(
    driver_class=None,
    css_path=None,
    watch_css=False,
    ansi_color=False,
)

Bases: Generic[ReturnType], DOMNode

The base class for Textual Applications.

Parameters:

Name Type Description Default

driver_class

Type[Driver] | None

Driver class or None to auto-detect. This will be used by some Textual tools.

None

css_path

CSSPathType | None

Path to CSS or None to use the CSS_PATH class variable. To load multiple CSS files, pass a list of strings or paths which will be loaded in order.

None

watch_css

bool

Reload CSS if the files changed. This is set automatically if you are using textual run with the dev switch.

False

ansi_color

bool

Allow ANSI colors if True, or convert ANSI colors to to RGB if False.

False

Raises:

Type Description
CssPathError

When the supplied CSS path(s) are an unexpected type.

ALLOW_IN_MAXIMIZED_VIEW class-attribute

ALLOW_IN_MAXIMIZED_VIEW = 'Footer'

The default value of Screen.ALLOW_IN_MAXIMIZED_VIEW.

ALLOW_SELECT class-attribute

ALLOW_SELECT = True

A switch to toggle arbitrary text selection for the app.

Note that this doesn't apply to Input and TextArea which have builtin support for selection.

AUTO_FOCUS class-attribute

AUTO_FOCUS = '*'

A selector to determine what to focus automatically when a screen is activated.

The widget focused is the first that matches the given CSS selector. Setting to None or "" disables auto focus.

BINDINGS class-attribute

BINDINGS = [
    Binding(
        "ctrl+q",
        "quit",
        "Quit",
        tooltip="Quit the app and return to the command prompt.",
        show=False,