From a153d74fadafad58fbac8dfd115731c0d8d516e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eugenio=20Parodi=20=F0=9F=8C=B6=EF=B8=8F?= Date: Wed, 22 Jan 2025 17:14:02 +0000 Subject: [PATCH] moved apps in the apps folder --- TermTk/TTkCore/color.py | 2 +- TermTk/TTkCore/filebuffer.py | 19 ++- run.dumbPaintTool.sh | 2 +- run.ttkDesigner.sh | 2 +- tests/sandbox/standalone.asyncio.html | 110 ++++++++++++++++++ .../t.generic/test.asyncio.001.multi.loop.py | 49 ++++++++ tools/webExporterInit.sh | 13 ++- 7 files changed, 178 insertions(+), 19 deletions(-) create mode 100644 tests/sandbox/standalone.asyncio.html create mode 100755 tests/t.generic/test.asyncio.001.multi.loop.py diff --git a/TermTk/TTkCore/color.py b/TermTk/TTkCore/color.py index 37d14ddc..f19b413a 100644 --- a/TermTk/TTkCore/color.py +++ b/TermTk/TTkCore/color.py @@ -394,7 +394,7 @@ class _TTkColor_mod_link(_TTkColor_mod): c = self.copy() c._clean = False return other + c - + # self + other def __add__(self, other): # TTkLog.debug("__add__") diff --git a/TermTk/TTkCore/filebuffer.py b/TermTk/TTkCore/filebuffer.py index 52754caa..ac4c4225 100644 --- a/TermTk/TTkCore/filebuffer.py +++ b/TermTk/TTkCore/filebuffer.py @@ -28,16 +28,15 @@ import threading from TermTk.TTkCore.log import TTkLog from TermTk.TTkCore.signal import pyTTkSignal -''' - w1 w3 w2 w5 - Buffer |----|----|----|----| cache buffer - | \ / \ - | x \ - | / \ \ - Pages | 0 | 2 | 1 |None| 3 |None| index to buffer - File |----|----|----|----|----|----| view as list of windows - w1 w2 w3 w4 w5 w6 -''' +# w1 w3 w2 w5 +# Buffer |----|----|----|----| cache buffer +# | \ / \ +# | x \ +# | / \ \ +# Pages | 0 | 2 | 1 |None| 3 |None| index to buffer +# File |----|----|----|----|----|----| view as list of windows +# w1 w2 w3 w4 w5 w6 + class TTkFileBuffer(): class _Page: __slots__ = ('_page', '_size', '_buffer') diff --git a/run.dumbPaintTool.sh b/run.dumbPaintTool.sh index de5c0130..3be613d4 100755 --- a/run.dumbPaintTool.sh +++ b/run.dumbPaintTool.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -PYTHONPATH=$(pwd)/tools python3 -m dumbPaintTool $@ \ No newline at end of file +PYTHONPATH=$(pwd)/apps python3 -m dumbPaintTool $@ \ No newline at end of file diff --git a/run.ttkDesigner.sh b/run.ttkDesigner.sh index 2d017821..9b1b3d0e 100755 --- a/run.ttkDesigner.sh +++ b/run.ttkDesigner.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -PYTHONPATH=$(pwd)/tools python3 -m ttkDesigner $@ \ No newline at end of file +PYTHONPATH=$(pwd)/apps python3 -m ttkDesigner $@ \ No newline at end of file diff --git a/tests/sandbox/standalone.asyncio.html b/tests/sandbox/standalone.asyncio.html new file mode 100644 index 00000000..65f9fe07 --- /dev/null +++ b/tests/sandbox/standalone.asyncio.html @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + +
+ + + + + + diff --git a/tests/t.generic/test.asyncio.001.multi.loop.py b/tests/t.generic/test.asyncio.001.multi.loop.py new file mode 100755 index 00000000..64db8c9c --- /dev/null +++ b/tests/t.generic/test.asyncio.001.multi.loop.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +# MIT License +# +# Copyright (c) 2025 Eugenio Parodi +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import asyncio + +# Define the first endless loop +async def loop_one(): + while True: + print("Running loop one...") + await asyncio.sleep(1) # Non-blocking sleep + +# Define the second endless loop +async def loop_two(): + while True: + print("Running loop two...") + await asyncio.sleep(2) # Non-blocking sleep + +# Main entry point +async def main(): + # Create and run tasks for the loops + task1 = asyncio.create_task(loop_one()) + task2 = asyncio.create_task(loop_two()) + + # Keep the program running indefinitely + await asyncio.gather(task1, task2) + +# Run the event loop +asyncio.run(main()) diff --git a/tools/webExporterInit.sh b/tools/webExporterInit.sh index 2e06c4ba..5ad72ada 100755 --- a/tools/webExporterInit.sh +++ b/tools/webExporterInit.sh @@ -26,7 +26,8 @@ _PWD=`pwd` _TOOLS_BASE_PATH=$(dirname $(readlink -f $0)) _BASE_PATH=$( readlink -f ${_TOOLS_BASE_PATH}/.. ) -_TMP_PATH=$( readlink -f ${_BASE_PATH}/tmp ) +_APPS_PATH=$( readlink -f ${_BASE_PATH}/apps ) +_TMP_PATH=$( readlink -f ${_BASE_PATH}/tmp ) _MAJOR=$( git describe --tags | sed 's,\([0-9]*\)\..*,\1,' ) _MINOR=$( git describe --tags | sed 's,[0-9]*\.\([0-9]*\)\..*,\1,' ) @@ -102,12 +103,12 @@ _download ${_TMP_PATH}/www/ www/favicon.ico tar cvzf ${_TMP_PATH}/bin/TermTk.tgz --exclude='__pycache__' --transform "s,^.*TermTk/,TermTk/," ${_TMP_PATH}/TermTk tar cvzf ${_TMP_PATH}/bin/DPT.tgz --exclude='__pycache__' --transform "s,^.*/dumbPaintTool,dumbPaintTool," \ - ${_TOOLS_BASE_PATH}/dumbPaintTool.py \ - ${_TOOLS_BASE_PATH}/dumbPaintTool/*.py \ - ${_TOOLS_BASE_PATH}/dumbPaintTool/app \ - ${_TOOLS_BASE_PATH}/dumbPaintTool/tui + ${_APPS_PATH}/dumbPaintTool.py \ + ${_APPS_PATH}/dumbPaintTool/*.py \ + ${_APPS_PATH}/dumbPaintTool/app \ + ${_APPS_PATH}/dumbPaintTool/tui -cp ${_TOOLS_BASE_PATH}/dumbPaintTool/web.ttk.package.json ${_TMP_PATH} +cp ${_APPS_PATH}/dumbPaintTool/web.ttk.package.json ${_TMP_PATH} cp -a ${_TOOLS_BASE_PATH}/webExporter/* ${_TMP_PATH}/