Browse Source

moved apps in the apps folder

pull/317/head
Eugenio Parodi 🌶️ 1 year ago
parent
commit
a153d74fad
  1. 2
      TermTk/TTkCore/color.py
  2. 19
      TermTk/TTkCore/filebuffer.py
  3. 2
      run.dumbPaintTool.sh
  4. 2
      run.ttkDesigner.sh
  5. 110
      tests/sandbox/standalone.asyncio.html
  6. 49
      tests/t.generic/test.asyncio.001.multi.loop.py
  7. 13
      tools/webExporterInit.sh

2
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__")

19
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')

2
run.dumbPaintTool.sh

@ -1,2 +1,2 @@
#!/usr/bin/env bash
PYTHONPATH=$(pwd)/tools python3 -m dumbPaintTool $@
PYTHONPATH=$(pwd)/apps python3 -m dumbPaintTool $@

2
run.ttkDesigner.sh

@ -1,2 +1,2 @@
#!/usr/bin/env bash
PYTHONPATH=$(pwd)/tools python3 -m ttkDesigner $@
PYTHONPATH=$(pwd)/apps python3 -m ttkDesigner $@

110
tests/sandbox/standalone.asyncio.html

@ -0,0 +1,110 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="icon" type="image/x-icon" href="www/favicon.ico">
<script src="www/pyodide/pyodide.js"></script>
<link href="www/xterm/xterm.css" rel="stylesheet" />
<script src="www/xterm/xterm.js"></script>
<script src="www/xterm/addon-fit/addon-fit.js"></script>
<!--
<script src="www/xterm/addon-canvas/addon-canvas.js"></script>
-->
<script src="www/xterm/addon-unicode11/addon-unicode11.js"></script>
<script src="www/file-saver/FileSaver.js"></script>
<style>
body {
height: 100%;
overflow-y: hidden;
overflow-x: hidden;
}
.xterm .xterm-viewport {overflow-y: hidden;}
</style>
</head>
<body>
<div id="terminal" oncontextmenu="return false;" style="float: left"></div>
<input type="file" id="file-input" hidden />
<script type="module">
import { TTkProxy } from './js/ttkproxy.js'
function pasteFunction(abc) {
text = abc.clipboardData.getData("Text")
console.log(`Pasted: ${text}`);
}
const font = new FontFace("pyTermTkFont", "url(www/fonts/opentype/3270-Regular.otf)");
document.fonts.add(font);
font.load();
document.fonts.ready.then(() => {main()});
/* pyodide demo */
async function mainTTk(term){
let ttkProxy = new TTkProxy(term)
await ttkProxy.init()
ttkProxy.namespace = ttkProxy.pyodide.globals.get("dict")();
await ttkProxy.pyodide.runPython(`
import asyncio
print('Hello from 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())
# main()
_loop=async_pyodide.CustomLoop()
asyncio.set_event_loop(_loop)
_loop.set_task_to_run_until_done(main())
`,{ globals: ttkProxy.namespace }
);
}
function main(){
/* xterm.js */
var term = new Terminal({
allowProposedApi: true,
fontSize: 17,
// fontFamily: 'FreeSerif Regular'});
fontFamily: 'pyTermTkFont'});
/* https://www.npmjs.com/package/@xterm/addon-unicode11 */
const unicode11Addon = new Unicode11Addon.Unicode11Addon();
// term.loadAddon(new CanvasAddon.CanvasAddon());
term.loadAddon(unicode11Addon);
term.unicode.activeVersion = '11';
term.open(document.getElementById('terminal'));
term.write('\n\rxterm.js - Loaded\n\r')
mainTTk(term)
}
</script>
</body>
</html>

49
tests/t.generic/test.asyncio.001.multi.loop.py

@ -0,0 +1,49 @@
#!/usr/bin/env python3
# MIT License
#
# Copyright (c) 2025 Eugenio Parodi <ceccopierangiolieugenio AT googlemail DOT com>
#
# 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())

13
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}/

Loading…
Cancel
Save