textual
The root Textual module.
Exposes some commonly used symbols.
log
module-attribute
¶
Logger ¶
A logger class that logs to the Textual console.
on ¶
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 |
---|---|---|---|
message_type |
type[Message]
|
The message type (i.e. the class). |
required |
selector |
str | None
|
An optional selector. If supplied, the handler will only be called if |
None
|
**kwargs |
str
|
Additional selectors for other attributes of the message. |
{}
|
work ¶
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 |
---|---|---|---|
method |
Callable[FactoryParamSpec, ReturnType] | Callable[FactoryParamSpec, Coroutine[None, None, ReturnType]] | None
|
A function or coroutine. |
None
|
name |
str
|
A short string to identify the worker (in logs and debugging). |
''
|
group |
str
|
A short string to identify a group of workers. |
'default'
|
exit_on_error |
bool
|
Exit the app if the worker raises an error. Set to |
True
|
exclusive |
bool
|
Cancel all workers in the same group. |
False
|
description |
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
|
thread |
bool
|
Mark the method as a thread worker. |
False
|