diff --git a/README.md b/README.md index c2e49f1..61ce1a4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Clock -*Event scheduler designed for asyncgui programs.* +Provides async time-related functionality. ```python import asyncgui @@ -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 @@ -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. @@ -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) diff --git a/src/asyncgui_ext/clock.py b/src/asyncgui_ext/clock.py index df2ea8c..17ec13f 100644 --- a/src/asyncgui_ext/clock.py +++ b/src/asyncgui_ext/clock.py @@ -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 ''' @@ -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): @@ -440,7 +440,7 @@ 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:: @@ -448,6 +448,16 @@ def anim_attrs(self, obj, *, duration, step=0, transition=_linear, **animated_pr 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)