textual.message_pump
A MessagePump
is a base class for any object which processes messages, which includes Widget, Screen, and App.
Tip
Most of the method here are useful in general app development.
MessagePump
¶
Base class which supplies a message pump.
app
property
¶
Get the current app.
Returns:
Type | Description |
---|---|
'App[object]'
|
The current app. |
Raises:
Type | Description |
---|---|
NoActiveAppError
|
if no active app could be found for the current asyncio context |
message_signal
instance-attribute
¶
message_signal = Signal(self, 'messages')
Subscribe to this signal to be notified of all messages sent to this widget.
This is a fairly low-level mechanism, and shouldn't replace regular message handling.
call_after_refresh
¶
call_after_refresh(callback, *args, **kwargs)
Schedule a callback to run after all messages are processed and the screen has been refreshed. Positional and keyword arguments are passed to the callable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Callback
|
A callable. |
required |
Returns:
Type | Description |
---|---|
bool
|
|
call_later
¶
Schedule a callback to run after all messages are processed in this object. Positional and keywords arguments are passed to the callable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Callback
|
Callable to call next. |
required |
|
Any
|
Positional arguments to pass to the callable. |
()
|
|
Any
|
Keyword arguments to pass to the callable. |
{}
|
Returns:
Type | Description |
---|---|
bool
|
|
call_next
¶
Schedule a callback to run immediately after processing the current message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Callback
|
Callable to run after current event. |
required |
|
Any
|
Positional arguments to pass to the callable. |
()
|
|
Any
|
Keyword arguments to pass to the callable. |
{}
|
prevent
¶
set_interval
¶
Call a function at periodic intervals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
float
|
Time (in seconds) between calls. |
required |
|
TimerCallback | None
|
Function to call. |
None
|
|
str | None
|
Name of the timer object. |
None
|
|
int
|
Number of times to repeat the call or 0 for continuous. |
0
|
|
bool
|
Start the timer paused. |
False
|
Returns:
Type | Description |
---|---|
Timer
|
A timer object. |
set_timer
¶
Call a function after a delay.
Example
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
float
|
Time (in seconds) to wait before invoking callback. |
required |
|
TimerCallback | None
|
Callback to call after time has expired. |
None
|
|
str | None
|
Name of the timer (for debug). |
None
|
|
bool
|
Start timer paused. |
False
|
Returns:
Type | Description |
---|---|
Timer
|
A timer object. |