Skip to content

Edit docs #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Clock

*Event scheduler designed for asyncgui programs.*
Provides async time-related functionality.

```python
import asyncgui
Expand All @@ -14,11 +14,11 @@ async def async_fn():

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'.
clock.tick(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.tick()`` in a loop or schedule it to be called repeatedly using another scheduling API.
In a real-world program, you probably want to call ``clock.tick()`` in a main loop.
For example, if you are using `PyGame`, you may want to do:

```python
Expand All @@ -33,15 +33,6 @@ while running:
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.
Expand All @@ -58,7 +49,3 @@ pip install "asyncgui-ext-clock>=0.5,<0.6"
- CPython 3.12
- CPython 3.13
- PyPy 3.10

## Misc

- [YouTube Demo](https://youtu.be/kPVzO8fF0yg) (with Kivy)
16 changes: 13 additions & 3 deletions src/asyncgui_ext/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ async def interpolate_scalar(self, start, end, *, duration, step=0, transition=_

interpolate = interpolate_scalar
'''
An alias for :meth:`interpolate_scalar`.
An alias of :meth:`interpolate_scalar`.

.. versionadded:: 0.5.2
'''
Expand Down Expand Up @@ -380,7 +380,7 @@ async def interpolate_sequence(self, start, end, *, duration, step=0, transition

interpolate_seq = interpolate_sequence
'''
An alias for :meth:`interpolate_sequence`.
An alias of :meth:`interpolate_sequence`.
'''

def _update(setattr, zip, min, obj, duration, transition, anim_params, task, p_time, dt):
Expand Down Expand Up @@ -440,14 +440,24 @@ def _anim_attrs(

def anim_attrs(self, obj, *, duration, step=0, transition=_linear, **animated_properties) -> Awaitable:
'''
Animates attibutes of any object.
Animates attributes of any object.

.. code-block::

import types

obj = types.SimpleNamespace(x=0, size=(200, 300))
await clock.anim_attrs(obj, x=100, size=(400, 400), duration=2)

Only numbers and flat numeric sequences are supported.
Nested sequences and dictionaries are not supported.

.. code-block::

await anim_attrs(obj, dictionary={'x': 1.}) # not supported
await anim_attrs(obj, nested_sequence=[[10, 20, ]]) # not supported

await anim_attrs(obj, number=1, flat_sequence=(100, 200)) # OK
'''
return self._anim_attrs(obj, duration, step, transition, animated_properties)

Expand Down