asyncgui-ext-clock


Nameasyncgui-ext-clock JSON
Version 0.5.2 PyPI version JSON
download
home_pagehttps://github.com/asyncgui/asyncgui-ext-clock
SummaryAn event scheduler for asyncgui programs
upload_time2024-12-07 00:35:32
maintainerNone
docs_urlNone
authorNattōsai Mitō
requires_python<4.0,>=3.10
licenseMIT
keywords async
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Clock

*Event scheduler designed for asyncgui programs.*

```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.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:

```python
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:

```python
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.5
pip install "asyncgui-ext-clock>=0.5,<0.6"
```

## Tested on

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

## Misc

- [YouTube Demo](https://youtu.be/kPVzO8fF0yg) (with Kivy)

            

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/b7/24/9aac44e939f8c35407db57fecf9ce8eb11b5a47ec73c665c9a2d001f165e/asyncgui_ext_clock-0.5.2.tar.gz",
    "platform": null,
    "description": "# Clock\n\n*Event scheduler designed for asyncgui programs.*\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.tick(10)  # Advances the clock by 10 time units.\nclock.tick(10)  # Total of 20 time units. The task above 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.tick()`` in a loop or schedule it to be called repeatedly using another scheduling API.\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.tick(dt)\n```\n\nAnd if you are using `Kivy`, you may want to do:\n\n```python\nfrom kivy.clock import Clock\n\nclock = asyncui_ext.clock.Clock()\nClock.schedule_interval(clock.tick, 0)\n```\n\n## Installation\n\nPin the minor version.\n\n```\npoetry add asyncgui-ext-clock@~0.5\npip install \"asyncgui-ext-clock>=0.5,<0.6\"\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\n## Misc\n\n- [YouTube Demo](https://youtu.be/kPVzO8fF0yg) (with Kivy)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An event scheduler for asyncgui programs",
    "version": "0.5.2",
    "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": "3e3b96b5ae840d5d4387a8fb9352029c3962968f0229e2291fd89c6b19d2bc94",
                "md5": "80a07a3627d7c3f28f86bbb1037b1db0",
                "sha256": "c857ec6f52b1d8471b9654989e27d57e6bfec97214e36bfc7a470c0feed2047e"
            },
            "downloads": -1,
            "filename": "asyncgui_ext_clock-0.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "80a07a3627d7c3f28f86bbb1037b1db0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 6930,
            "upload_time": "2024-12-07T00:35:29",
            "upload_time_iso_8601": "2024-12-07T00:35:29.898052Z",
            "url": "https://files.pythonhosted.org/packages/3e/3b/96b5ae840d5d4387a8fb9352029c3962968f0229e2291fd89c6b19d2bc94/asyncgui_ext_clock-0.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b7249aac44e939f8c35407db57fecf9ce8eb11b5a47ec73c665c9a2d001f165e",
                "md5": "3a5218b67a83e0abe5dcfc7278e67345",
                "sha256": "22c6efc8d8da6194e500e5f190ad978352a57e1e4289beab4059a2421a25b6b3"
            },
            "downloads": -1,
            "filename": "asyncgui_ext_clock-0.5.2.tar.gz",
            "has_sig": false,
            "md5_digest": "3a5218b67a83e0abe5dcfc7278e67345",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 6603,
            "upload_time": "2024-12-07T00:35:32",
            "upload_time_iso_8601": "2024-12-07T00:35:32.415321Z",
            "url": "https://files.pythonhosted.org/packages/b7/24/9aac44e939f8c35407db57fecf9ce8eb11b5a47ec73c665c9a2d001f165e/asyncgui_ext_clock-0.5.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-07 00:35:32",
    "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"
}
        
Elapsed time: 0.51002s