An event scheduler for asyncgui programs
Project description
Clock
Event scheduler designed for asyncgui programs.
import asyncgui
from asyncgui_ext.clock import Clock
clock = Clock()
async def async_fn():
await clock.sleep(20) # Waits for 20 time units
print("Hello")
asyncgui.start(async_fn())
clock.tick(10) # Advances the clock by 10 time units.
clock.tick(10) # Total of 20 time units. The task above will wake up, and prints 'Hello'.
The example above effectively illustrate how this module works but it's not practical.
In a real-world program, you probably want to call clock.tick()
in a loop or schedule it to be called repeatedly using another scheduling API.
For example, if you are using PyGame
, you may want to do:
pygame_clock = pygame.time.Clock()
clock = asyncgui_ext.clock.Clock()
# main loop
while running:
...
dt = pygame_clock.tick(fps)
clock.tick(dt)
And if you are using Kivy
, you may want to do:
from kivy.clock import Clock
clock = asyncui_ext.clock.Clock()
Clock.schedule_interval(clock.tick, 0)
Installation
Pin the minor version.
poetry add asyncgui-ext-clock@~0.4
pip install "asyncgui-ext-clock>=0.4,<0.5"
Tested on
- CPython 3.10
- CPython 3.11
- CPython 3.12
Misc
- YouTube Demo (with Kivy)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file asyncgui_ext_clock-0.4.0.tar.gz
.
File metadata
- Download URL: asyncgui_ext_clock-0.4.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.4 Linux/5.4.0-189-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dea8f51400b5f9f8fbbcf75a7c4f2de74446afa855ed5e835d7b92b5929145f3 |
|
MD5 | b10455c2b843544f9958796ae30b6770 |
|
BLAKE2b-256 | 47c432aae943b5c10de58eb8a2ab3dbb95e3d8ec4781fe31919bbedf1d9e9284 |
Provenance
File details
Details for the file asyncgui_ext_clock-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: asyncgui_ext_clock-0.4.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.4 Linux/5.4.0-189-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0356738cf6ca50d6d34954ddaa62c0f45c4fd61d57b69b20ac96fcd4e38c5ad9 |
|
MD5 | dad0c37ed10e2d8a95bbd167367aecf9 |
|
BLAKE2b-256 | 05b40924dce62d9cd47305b0b03d72ef3ccc8c3f3e9aaa060057c41bcf1b5be6 |