asyncgui-ext-clock


Nameasyncgui-ext-clock JSON
Version 0.5.1 PyPI version JSON
download
home_pagehttps://github.com/asyncgui/asyncgui-ext-clock
SummaryAn event scheduler for asyncgui programs
upload_time2024-08-31 00:39:47
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

## 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/2c/a3/6f56bc9eb92572e9981dd4a8cd1864d8ff1c304752e1261e4325b9000271/asyncgui_ext_clock-0.5.1.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\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.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": "d98cb20636cd11fd44a23b6c9840d9cff58e916c6b95c241058dcc22ef465e18",
                "md5": "725fd08945647bae709a792faad5d13a",
                "sha256": "511ebdfaf644f2f3e30b6c9656345c0781c994b0d63ce7b51dbd7a098a164a4e"
            },
            "downloads": -1,
            "filename": "asyncgui_ext_clock-0.5.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "725fd08945647bae709a792faad5d13a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 6893,
            "upload_time": "2024-08-31T00:39:46",
            "upload_time_iso_8601": "2024-08-31T00:39:46.923192Z",
            "url": "https://files.pythonhosted.org/packages/d9/8c/b20636cd11fd44a23b6c9840d9cff58e916c6b95c241058dcc22ef465e18/asyncgui_ext_clock-0.5.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ca36f56bc9eb92572e9981dd4a8cd1864d8ff1c304752e1261e4325b9000271",
                "md5": "d22164c779ffcf5ce4105dbb50aba1b6",
                "sha256": "275950dbcc0d7145c34f026f49aaf70d76e877223b673be38d2076c6d286fcfb"
            },
            "downloads": -1,
            "filename": "asyncgui_ext_clock-0.5.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d22164c779ffcf5ce4105dbb50aba1b6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 6524,
            "upload_time": "2024-08-31T00:39:47",
            "upload_time_iso_8601": "2024-08-31T00:39:47.889058Z",
            "url": "https://files.pythonhosted.org/packages/2c/a3/6f56bc9eb92572e9981dd4a8cd1864d8ff1c304752e1261e4325b9000271/asyncgui_ext_clock-0.5.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-31 00:39:47",
    "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.64866s