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
class
¶
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 |
is_running
property
¶
Is the message pump running (potentially processing messages)?
call_after_refresh
method
¶
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
Parameter | Default | Description |
---|---|---|
callback
Callback
|
required | A callable. |
Returns
Type | Description |
---|---|
bool
|
|
call_later
method
¶
Schedule a callback to run after all messages are processed in this object. Positional and keywords arguments are passed to the callable.
Parameters
Parameter | Default | Description |
---|---|---|
callback
Callback
|
required | Callable to call next. |
*args
Any
|
()
|
Positional arguments to pass to the callable. |
**kwargs
Any
|
{}
|
Keyword arguments to pass to the callable. |
Returns
Type | Description |
---|---|
bool
|
|
call_next
method
¶
check_idle
method
¶
Prompt the message pump to call idle if the queue is empty.
check_message_enabled
method
¶
disable_messages
method
¶
Disable message types from being processed.
dispatch_key
async
¶
Dispatch a key event to method.
This method will call the method named 'key_
Parameters
Parameter | Default | Description |
---|---|---|
event
events.Key
|
required | A key event. |
Returns
Type | Description |
---|---|
bool
|
True if key was handled, otherwise False. |
Raises
Type | Description |
---|---|
DuplicateKeyHandlers
|
When there's more than 1 handler that could handle this key. |
on_event
async
¶
post_message
method
¶
prevent
method
¶
set_interval
method
¶
Call a function at periodic intervals.
Parameters
Parameter | Default | Description |
---|---|---|
interval
float
|
required | Time (in seconds) between calls. |
callback
TimerCallback | None
|
None
|
Function to call. |
name
str | None
|
None
|
Name of the timer object. |
repeat
int
|
0
|
Number of times to repeat the call or 0 for continuous. |
pause
bool
|
False
|
Start the timer paused. |
Returns
Type | Description |
---|---|
Timer
|
A timer object. |
set_timer
method
¶
Make a function call after a delay.
Parameters
Parameter | Default | Description |
---|---|---|
delay
float
|
required | Time (in seconds) to wait before invoking callback. |
callback
TimerCallback | None
|
None
|
Callback to call after time has expired. |
name
str | None
|
None
|
Name of the timer (for debug). |
pause
bool
|
False
|
Start timer paused. |
Returns
Type | Description |
---|---|
Timer
|
A timer object. |