textual
The root Textual module.
Exposes some commonly used symbols.
Logger
¶
A logger class that logs to the Textual console.
on
¶
on(message_type, selector=None, **kwargs)
Decorator to declare that the method is a message handler.
The decorator accepts an optional CSS selector that will be matched against a widget exposed by
a control
property on the message.
Example
Keyword arguments can be used to match additional selectors for attributes
listed in ALLOW_SELECTOR_MATCH
.
Example
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
type[Message]
|
The message type (i.e. the class). |
required |
|
str | None
|
An optional selector. If supplied, the handler will only be called if |
None
|
|
str
|
Additional selectors for other attributes of the message. |
{}
|
work
¶
work(
method: Callable[
FactoryParamSpec, Coroutine[None, None, ReturnType]
],
*,
name: str = "",
group: str = "default",
exit_on_error: bool = True,
exclusive: bool = False,
description: str | None = None,
thread: bool = False
) -> Callable[FactoryParamSpec, "Worker[ReturnType]"]
work(
method=None,
*,
name="",
group="default",
exit_on_error=True,
exclusive=False,
description=None,
thread=False
)
A decorator used to create workers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Callable[FactoryParamSpec, ReturnType] | Callable[FactoryParamSpec, Coroutine[None, None, ReturnType]] | None
|
A function or coroutine. |
None
|
|
str
|
A short string to identify the worker (in logs and debugging). |
''
|
|
str
|
A short string to identify a group of workers. |
'default'
|
|
bool
|
Exit the app if the worker raises an error. Set to |
True
|
|
bool
|
Cancel all workers in the same group. |
False
|
|
str | None
|
Readable description of the worker for debugging purposes. By default, it uses a string representation of the decorated method and its arguments. |
None
|
|
bool
|
Mark the method as a thread worker. |
False
|