# 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.
```
poetry add asyncgui-ext-clock@~0.6
pip install "asyncgui-ext-clock>=0.6,<0.7"
```
## Tested on
- CPython 3.10
- CPython 3.11
- CPython 3.12
- CPython 3.13
- PyPy 3.10
Raw data
{
"_id": null,
"home_page": "https://github.com/asyncgui/asyncgui-ext-clock",
"name": "asyncgui-ext-clock",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "async",
"author": "Natt\u014dsai Mit\u014d",
"author_email": "flow4re2c@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/57/a0/ac6d835888b97b1ccbe77e8ef210cbc0afeb29fffda337c7ce864c86ebc0/asyncgui_ext_clock-0.6.1.tar.gz",
"platform": null,
"description": "# Clock\n\n```python\nimport asyncgui\nfrom asyncgui_ext.clock import Clock\n\nclock = Clock()\n\nasync def async_fn():\n await clock.sleep(20) # Waits for 20 time units\n print(\"Hello\")\n\nasyncgui.start(async_fn())\nclock.advance(10) # Advances the clock by 10 time units.\nclock.advance(10) # Total of 20 time units. The async_fn will wake up, and prints 'Hello'.\n```\n\nThe example above effectively illustrate how this module works but it's not practical.\nIn a real-world program, you probably want to call ``clock.advance()`` in a main loop.\nFor example, if you are using `PyGame`, you may want to do:\n\n```python\npygame_clock = pygame.time.Clock()\nclock = asyncgui_ext.clock.Clock()\n\n# main loop\nwhile running:\n ...\n\n dt = pygame_clock.tick(fps)\n clock.advance(dt)\n```\n\n## Installation\n\nPin the minor version.\n\n```\npoetry add asyncgui-ext-clock@~0.6\npip install \"asyncgui-ext-clock>=0.6,<0.7\"\n```\n\n## Tested on\n\n- CPython 3.10\n- CPython 3.11\n- CPython 3.12\n- CPython 3.13\n- PyPy 3.10\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An event scheduler for asyncgui programs",
"version": "0.6.1",
"project_urls": {
"Homepage": "https://github.com/asyncgui/asyncgui-ext-clock",
"Repository": "https://github.com/asyncgui/asyncgui-ext-clock"
},
"split_keywords": [
"async"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "df9e7e7eb2b5b779a9c9686e9b0b7648cf595c211c31ed5113038577babfa3f3",
"md5": "4d4e91ab671e72e3eda613d96e888c08",
"sha256": "50f63300e89ddb8a1c95b586c5a2ba577b27211ecc4af7cc563c60fb5dd9d044"
},
"downloads": -1,
"filename": "asyncgui_ext_clock-0.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4d4e91ab671e72e3eda613d96e888c08",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 6612,
"upload_time": "2025-08-30T22:15:52",
"upload_time_iso_8601": "2025-08-30T22:15:52.294968Z",
"url": "https://files.pythonhosted.org/packages/df/9e/7e7eb2b5b779a9c9686e9b0b7648cf595c211c31ed5113038577babfa3f3/asyncgui_ext_clock-0.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "57a0ac6d835888b97b1ccbe77e8ef210cbc0afeb29fffda337c7ce864c86ebc0",
"md5": "7085e87369c50c6f5cc2ddb3713dc7f3",
"sha256": "fd754f594bef07fd588c01cbda045f7a137134a964ab3324fa2bf73d204c3f2f"
},
"downloads": -1,
"filename": "asyncgui_ext_clock-0.6.1.tar.gz",
"has_sig": false,
"md5_digest": "7085e87369c50c6f5cc2ddb3713dc7f3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 6071,
"upload_time": "2025-08-30T22:15:53",
"upload_time_iso_8601": "2025-08-30T22:15:53.482087Z",
"url": "https://files.pythonhosted.org/packages/57/a0/ac6d835888b97b1ccbe77e8ef210cbc0afeb29fffda337c7ce864c86ebc0/asyncgui_ext_clock-0.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-30 22:15:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "asyncgui",
"github_project": "asyncgui-ext-clock",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "asyncgui-ext-clock"
}