Skip to content
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

changed async def to @asyncio.coroutine #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion CanvasPlus/_errors.py
Original file line number Diff line number Diff line change
@@ -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
"""
Expand Down
2 changes: 1 addition & 1 deletion CanvasPlus/assets/asynctransformations.py
Original file line number Diff line number Diff line change
@@ -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
"""
Expand Down
22 changes: 13 additions & 9 deletions CanvasPlus/pythonBelow35Assets/asynctransformations.py
Original file line number Diff line number Diff line change
@@ -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
"""
Expand All @@ -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
"""
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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).
Expand Down Expand Up @@ -130,4 +134,4 @@ async def async_rotate(

if update:
self.tk.call("update")
await asyncio.sleep(timeIncrement)
yield from asyncio.sleep(timeIncrement)