Skip to main content

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

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

asyncgui_ext_clock-0.5.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

asyncgui_ext_clock-0.5.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file asyncgui_ext_clock-0.5.0.tar.gz.

File metadata

  • Download URL: asyncgui_ext_clock-0.5.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-192-generic

File hashes

Hashes for asyncgui_ext_clock-0.5.0.tar.gz
Algorithm Hash digest
SHA256 fab33d3b6baf9c071c9da1682f9ba9393cc5cf65a20190403dd72531d0ba2c2c
MD5 0d91cbd21ac02eb9bcead57882f3cf02
BLAKE2b-256 c8403e7c2a355f57e12e90e9afbf68b233e8508c97affa0f4610563889f28977

See more details on using hashes here.

Provenance

File details

Details for the file asyncgui_ext_clock-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: asyncgui_ext_clock-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.4 Linux/5.4.0-192-generic

File hashes

Hashes for asyncgui_ext_clock-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a315fab389e38b8393cea76e4b3241a24f059a443a65057f7ac5ec8ede5e5be9
MD5 78e492e892a407ca42ab6bee48b1cba6
BLAKE2b-256 51d3be9f105bed5cf19da4adf58a007eec9fd05881bac05d51ea38606149a88c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page