Skip to content

textual.types

Export some objects that are used by Textual and that help document other features.

ActionParseResult module-attribute

ActionParseResult = 'tuple[str, str, tuple[object, ...]]'

An action is its name and the arbitrary tuple of its arguments.

AnimationLevel module-attribute

AnimationLevel = Literal['none', 'basic', 'full']

The levels that the TEXTUAL_ANIMATIONS env var can be set to.

CSSPathType module-attribute

CSSPathType = Union[
    str, PurePath, List[Union[str, PurePath]]
]

Valid ways of specifying paths to CSS files.

CallbackType module-attribute

CallbackType = Union[
    Callable[[], Awaitable[None]], Callable[[], None]
]

Type used for arbitrary callables used in callbacks.

Direction module-attribute

Direction = Literal[-1, 1]

Valid values to determine navigation direction.

In a vertical setting, 1 points down and -1 points up. In a horizontal setting, 1 points right and -1 points left.

EasingFunction module-attribute

EasingFunction = Callable[[float], float]

Signature for a function that parametrizes animation speed.

An easing function must map the interval [0, 1] into the interval [0, 1].

IgnoreReturnCallbackType module-attribute

IgnoreReturnCallbackType = Union[
    Callable[[], Awaitable[Any]], Callable[[], Any]
]

A callback which ignores the return type.

InputValidationOn module-attribute

InputValidationOn = Literal['blur', 'changed', 'submitted']

Possible messages that trigger input validation.

OptionListContent module-attribute

OptionListContent = 'Option | VisualType | None'

Types accepted in OptionList constructor and [add_options()][textual.widgets.OptionList.ads_options].

PlaceholderVariant module-attribute

PlaceholderVariant = Literal['default', 'size', 'text']

The different variants of placeholder.

SelectType module-attribute

SelectType = TypeVar('SelectType', bound=Hashable)

The type used for data in the Select.

WatchCallbackType module-attribute

WatchCallbackType = Union[
    WatchCallbackBothValuesType,
    WatchCallbackNewValueType,
    WatchCallbackNoArgsType,
]

Type used for callbacks passed to the watch method of widgets.

Animatable

Bases: Protocol

Protocol for objects that can have their intrinsic values animated.

For example, the transition between two colors can be animated because the class Color satisfies this protocol.

CSSPathError

Bases: Exception

Raised when supplied CSS path(s) are invalid.

DirEntry dataclass

DirEntry(path, loaded=False)

Attaches directory information to a DirectoryTree node.

loaded class-attribute instance-attribute

loaded = False

Has this been loaded?

path instance-attribute

path

The path of the directory entry.

DuplicateID

Bases: OptionListError

Raised if a duplicate ID is used when adding options to an option list.

MessageTarget

Bases: Protocol

Protocol that must be followed by objects that can receive messages.

NoActiveAppError

Bases: RuntimeError

Runtime error raised if we try to retrieve the active app when there is none.

NoSelection

Used by the Select widget to flag the unselected state. See Select.BLANK.

OptionDoesNotExist

Bases: OptionListError

Raised when a request has been made for an option that doesn't exist.

RenderStyles

RenderStyles(node, base, inline_styles)

Bases: StylesBase

Presents a combined view of two Styles object: a base Styles and inline Styles.

base property