Metadata-Version: 2.4
Name: asyncgui-ext-clock
Version: 0.6.2
Summary: An event scheduler for asyncgui programs
Keywords: async
Author: Nattōsai Mitō
Author-email: Nattōsai Mitō <flow4re2c@gmail.com>
License-Expression: MIT
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries
Classifier: Operating System :: OS Independent
Requires-Dist: asyncgui>=0.9.3,<1
Requires-Python: >=3.10, <4
Project-URL: Documentation, https://asyncgui.github.io/asyncgui-ext-clock
Project-URL: Repository, https://github.com/asyncgui/asyncgui-ext-clock
Description-Content-Type: text/markdown

# Clock

```python
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.advance(10)  # Advances the clock by 10 time units.
clock.advance(10)  # Total of 20 time units. The async_fn 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.advance()`` in a main loop.
For example, if you are using `PyGame`, you may want to do:

```python
pygame_clock = pygame.time.Clock()
clock = asyncgui_ext.clock.Clock()

# main loop
while running:
    ...

    dt = pygame_clock.tick(fps)
    clock.advance(dt)
```

## Installation

Pin the minor version.

```
pip install "asyncgui-ext-clock>=0.6,<0.7"
```

## Tested on

- CPython 3.10
- CPython 3.11
- CPython 3.12
- CPython 3.13
- CPython 3.14
- PyPy 3.10
