appdev.app
App: devices, events, display refresh and lifecycle, on multimer’s timers.
An App owns no timer machinery of its own. app.every(ms, fn) is
multimer.every; the device service tick and each display’s refresh are
ordinary timers you can see in multimer.report(); and staying alive past
the end of the script body is multimer.keepalive, which the App sets
when it has a display or a subscription. So a script that builds its UI and
ends keeps running, at the prompt under -i and in the exit hook
otherwise, with or without LVGL, and app.run() is only for a program
that wants to block.
- class appdev.app.App(board_config=None, *, displays=None, host_read=None, touch_read=None, touch_rotation_table=None, refresh_period=None)[source]
Bases:
objectApplication coordinator: devices, event dispatch, display refresh, lifecycle.
- events = <module 'events' from '/home/docs/checkouts/pydevices/checkouts/178/docs-site/_repos/omnipython/lib/events.py'>
- keys = <module 'keys' from '/home/docs/checkouts/pydevices/checkouts/178/docs-site/_repos/omnipython/lib/keys.py'>
- property strategy
How the program stays alive past the script body (see
multimer.strategy).
- on_quit(callback)[source]
Call callback() at quit, after
before_quit, in the order added.Unlike
before_quit, any number of callbacks can be added, and adding one never replaces another. Returns callback, so it works as a decorator. An exception in one is printed and the rest still run.
- property timers
The App’s own timers: service, refresh and every() subscriptions.
- on(event_type_or_list, callback=None)[source]
Subscribe callback to one or more event types, or use as a decorator.
- every(ms=None, callback=None, *, period=None, name=None)[source]
A periodic
multimer.Timercallingcallback(timer)every ms.The callback receives the timer, so a method needs the signature
def step(self, timer=None). Usable as a decorator (@app.every(1000)). The App keeps the process alive while any subscription runs;timer.deinit()(orcancel()) ends one.
- stop_timer()
Stop the service tick, every refresh and every subscription.
- pause_polling()[source]
Stop the service tick reading the devices: the caller reads them.
A GUI that polls the input devices itself (LVGL reads its indevs from its own timers) claims the devices with this, or the service tick consumes the events first.
release()the claim to resume.
- poll()[source]
Poll registered devices and dispatch any pending events.
A program that calls this from its own loop takes over from the service timer; delivery of every other timer happens here too.
- run(tick_ms=10)[source]
Block until quit, delivering timers and events. Optional.
Returns at once where the host already owns a loop that keeps the program running (a REPL under
-i, a browser page, a notebook).