From 4b98c682cbd0a489b9c446941916b4562ad87ba0 Mon Sep 17 00:00:00 2001 From: Luke <55749227+Luke-zhang-04@users.noreply.github.com> Date: Sun, 10 May 2020 08:57:17 -0400 Subject: [PATCH] changed async def to @asyncio.coroutine --- CanvasPlus/_errors.py | 2 +- CanvasPlus/assets/asynctransformations.py | 2 +- .../asynctransformations.py | 22 +++++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CanvasPlus/_errors.py b/CanvasPlus/_errors.py index d1bcb2b..283028b 100644 --- a/CanvasPlus/_errors.py +++ b/CanvasPlus/_errors.py @@ -1,6 +1,6 @@ """defines errors for canvasplus.""" """Luke-zhang-04 -CanvasPlus v1.3.0 (https://github.com/Luke-zhang-04/CanvasPlus) +CanvasPlus (https://github.com/Luke-zhang-04/CanvasPlus) Copyright (C) 2020 Luke Zhang Licensed under the MIT License """ diff --git a/CanvasPlus/assets/asynctransformations.py b/CanvasPlus/assets/asynctransformations.py index b694d59..a0aaa6b 100644 --- a/CanvasPlus/assets/asynctransformations.py +++ b/CanvasPlus/assets/asynctransformations.py @@ -1,6 +1,6 @@ """Defines asynchronus transformations.""" """Luke-zhang-04 -CanvasPlus v1.3.0 (https://github.com/Luke-zhang-04/CanvasPlus) +CanvasPlus (https://github.com/Luke-zhang-04/CanvasPlus) Copyright (C) 2020 Luke Zhang Licensed under the MIT License """ diff --git a/CanvasPlus/pythonBelow35Assets/asynctransformations.py b/CanvasPlus/pythonBelow35Assets/asynctransformations.py index ff19935..f76fcb6 100644 --- a/CanvasPlus/pythonBelow35Assets/asynctransformations.py +++ b/CanvasPlus/pythonBelow35Assets/asynctransformations.py @@ -1,6 +1,6 @@ """Defines asynchronus transformations.""" """Luke-zhang-04 -CanvasPlus v1.3.0 (https://github.com/Luke-zhang-04/CanvasPlus) +CanvasPlus (https://github.com/Luke-zhang-04/CanvasPlus) Copyright (C) 2020 Luke Zhang Licensed under the MIT License """ @@ -21,7 +21,8 @@ class AsyncTransformations: """define asynchronus transformation methodsscreen.update()""" - async def async_morph(self, tagOrId, time, *coords, fps=24, update=True): + @asyncio.coroutine + def async_morph(self, tagOrId, time, *coords, fps=24, update=True): """Asynchronously morph tagOrId into *coords. fps: frames per second, time: specify the amount of time the animation shall take to complete, update: call update() method within loop """ @@ -52,9 +53,10 @@ async def async_morph(self, tagOrId, time, *coords, fps=24, update=True): if update: self.tk.call("update") - await asyncio.sleep(timeIncrement) + yield from asyncio.sleep(timeIncrement) - async def async_move(self, tagOrId, xDist, yDist, time, fps=24, update=True): + @asyncio.coroutine + def async_move(self, tagOrId, xDist, yDist, time, fps=24, update=True): """Asynchronously move tagOrId by xDist and yDist (x distance, y distance). fps: frames per second, time: specify the amount of time the animation shall take to complete, update: call update() method within loop @@ -74,9 +76,10 @@ async def async_move(self, tagOrId, xDist, yDist, time, fps=24, update=True): if update: self.tk.call("update") - await asyncio.sleep(timeIncrement) + yield from asyncio.sleep(timeIncrement) - async def async_resize(self, tagOrId, scale, x, y, time, fps=24, update=True): + @asyncio.coroutine + def async_resize(self, tagOrId, scale, x, y, time, fps=24, update=True): """Asynchronously resize tagOrId with point x, y and scale. fps: frames per second, time: specify the amount of time the animation shall take to complete, update: call update() method within loop @@ -92,9 +95,10 @@ async def async_resize(self, tagOrId, scale, x, y, time, fps=24, update=True): if update: self.tk.call("update") - await asyncio.sleep(timeIncrement) + yield from asyncio.sleep(timeIncrement) - async def async_rotate( + @asyncio.coroutine + def async_rotate( self, tagOrId, x, y, time, amount, unit="rad", warn=True, fps=24, update=True, ): """Asynchronously rotate tagOrId on axis x, y by amount in degrees or radians clockwise (use negaitves for counter-clockwise). @@ -130,4 +134,4 @@ async def async_rotate( if update: self.tk.call("update") - await asyncio.sleep(timeIncrement) + yield from asyncio.sleep(timeIncrement)