From de3f78c6d86f48bd45bb34241d7d7bc8e5cbd254 Mon Sep 17 00:00:00 2001 From: Eugenio Parodi Date: Mon, 17 Apr 2023 19:15:00 +0100 Subject: [PATCH] Added ttkDesigner build/deploy scripts --- Makefile | 15 +- setup.ttkDesigner.py | 43 ++ tools/prepareBuild.sh | 24 +- ttkDesigner/README.md | 12 + ttkDesigner/app/about.py | 4 +- ttkDesigner/app/cfg.py | 2 +- tutorial/ttkDesigner/textEdit/textEdit.rst | 0 .../ttkDesigner/textEdit/textEdit.tui.json | 536 ++++++++++++++++++ 8 files changed, 627 insertions(+), 9 deletions(-) create mode 100644 setup.ttkDesigner.py create mode 100644 ttkDesigner/README.md create mode 100644 tutorial/ttkDesigner/textEdit/textEdit.rst create mode 100644 tutorial/ttkDesigner/textEdit/textEdit.tui.json diff --git a/Makefile b/Makefile index a783e8c2..d02c8c33 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ build: .venv . .venv/bin/activate ; \ tools/prepareBuild.sh release ; \ cd tmp ; \ - python3 -m build \ + python3 -m build deploy: .venv . .venv/bin/activate ; \ @@ -58,7 +58,18 @@ deploy: .venv buildTest: .venv . .venv/bin/activate ; \ tools/prepareBuild.sh test ; \ - python3 -m build ; \ + cd tmp ; \ + python3 -m build + +buildTTkDesigner: .venv + . .venv/bin/activate ; \ + tools/prepareBuild.sh ttkDesigner ; \ + cd tmp ; \ + python3 -m build + +deployTTkDesigner: .venv + . .venv/bin/activate ; \ + python3 -m twine upload tmp/dist/* deployDoc: git checkout gh-pages diff --git a/setup.ttkDesigner.py b/setup.ttkDesigner.py new file mode 100644 index 00000000..b25528c6 --- /dev/null +++ b/setup.ttkDesigner.py @@ -0,0 +1,43 @@ +from setuptools import setup + +with open("README.md", "r", encoding="utf-8") as fh: + long_description = fh.read() + +version = "__VERSION__" +name = "__NAME__" + +print(f"Version: {version}") +print(f"Name: {name}") + +setup( + name=name, + version=version, + author='Eugenio Parodi', + author_email='ceccopierangiolieugenio@googlemail.com', + description='ttkDesigner is a terminal user interface designer for pyTermTk applications', + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/ceccopierangiolieugenio/pyTermTk", + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "Topic :: Terminals", + "Topic :: Software Development :: User Interfaces"], + include_package_data=False, + packages=['ttkDesigner','ttkDesigner.app'], + python_requires=">=3.8", + install_requires=[ + 'pyTermTk>=0.30.0a5', + 'pyperclip', + 'PIL'], + entry_points={ + 'console_scripts': [ + 'ttkDesigner = ttkDesigner:main', + ], + }, +) \ No newline at end of file diff --git a/tools/prepareBuild.sh b/tools/prepareBuild.sh index b25e7723..206c57c3 100755 --- a/tools/prepareBuild.sh +++ b/tools/prepareBuild.sh @@ -58,9 +58,24 @@ case $1 in ;; test) _NAME='example-pkg-ceccopierangiolieugenio' + _BUILD_LIB='TermTk' + _SETUP='setup.py' + _README='README.md' + _CFG='TermTk/TTkCore/cfg.py' ;; release) _NAME='pyTermTk' + _BUILD_LIB='TermTk' + _SETUP='setup.py' + _README='README.md' + _CFG='TermTk/TTkCore/cfg.py' + ;; + ttkDesigner) + _NAME='ttkDesigner' + _BUILD_LIB='ttkDesigner' + _SETUP='setup.ttkDesigner.py' + _README='ttkDesigner/README.md' + _CFG='ttkDesigner/app/cfg.py' ;; *) echo "Option \"$2\" not recognized" @@ -76,8 +91,9 @@ echo Name: ${_NAME} mkdir -p ${_TMP_PATH} rm -rf ${_TMP_PATH}/* -cp setup.py README.md LICENSE ${_TMP_PATH} +cp ${_SETUP} ${_TMP_PATH}/setup.py +cp ${_README} LICENSE ${_TMP_PATH} -cp -a ${_BASE_PATH}/TermTk ${_TMP_PATH} -sed "s,__VERSION__,${_VERSION}," -i ${_TMP_PATH}/TermTk/TTkCore/cfg.py -sed "s,__NAME__,${_NAME}," -i ${_TMP_PATH}/TermTk/TTkCore/cfg.py +cp -a ${_BASE_PATH}/${_BUILD_LIB} ${_TMP_PATH} +sed "s,__VERSION__,${_VERSION}," -i ${_TMP_PATH}/${_CFG} ${_TMP_PATH}/setup.py +sed "s,__NAME__,${_NAME}," -i ${_TMP_PATH}/${_CFG} ${_TMP_PATH}/setup.py diff --git a/ttkDesigner/README.md b/ttkDesigner/README.md new file mode 100644 index 00000000..2f26d467 --- /dev/null +++ b/ttkDesigner/README.md @@ -0,0 +1,12 @@ +![Linux](https://img.shields.io/badge/-Linux-grey?logo=linux) +![Usage](https://img.shields.io/badge/Usage-Terminal%20User%20Interface-yellow) +![Python](https://img.shields.io/badge/Python-v3.8%5E-green?logo=python) +![pyTermTk_version](https://img.shields.io/github/v/tag/ceccopierangiolieugenio/pyTermTk?label=version) +[![Test Status](https://img.shields.io/github/actions/workflow/status/ceccopierangiolieugenio/pyTermTk/testing.yml?branch=main&label=tests)](https://github.com/ceccopierangiolieugenio/pyTermTk/actions?query=workflow%3Atesting) +[![pypi_version](https://img.shields.io/pypi/v/pyTermTk?label=pypi)](https://pypi.org/project/pyTermTk) +[![pypi_version](https://img.shields.io/twitter/follow/Pier95886803?style=social&logo=twitter)](https://twitter.com/hashtag/pyTermTk?src=hashtag_click&f=live) + +[![screenshot](https://user-images.githubusercontent.com/8876552/232550100-89e80528-85b1-40d8-b752-6dc5feedf3ae.png)](https://pypi.org/project/pyTermTk) + +## [ttkDesigner](https://github.com/ceccopierangiolieugenio/pyTermTk/ttkDesigner) + diff --git a/ttkDesigner/app/about.py b/ttkDesigner/app/about.py index 27fe4e6e..1886689f 100644 --- a/ttkDesigner/app/about.py +++ b/ttkDesigner/app/about.py @@ -24,7 +24,7 @@ from TermTk.TTkCore.log import TTkLog from TermTk.TTkCore.color import TTkColor from TermTk.TTkCore.string import TTkString from TermTk import TTkAbout, TTkWindow -from .cfg import TTKodeCfg +from .cfg import TTkDesignerCfg class About(TTkAbout): # designerTxt = [ @@ -51,7 +51,7 @@ class About(TTkAbout): c = [0xFF,0xFF,0xFF] for y, line in enumerate(About.designerTxt): self._canvas.drawText(pos=(13,3+y),text=line) - self._canvas.drawText(pos=(26, 9),text=f" Version: {TTKodeCfg.version}", color=TTkColor.fg('#AAAAFF')) + self._canvas.drawText(pos=(26, 9),text=f" Version: {TTkDesignerCfg.version}", color=TTkColor.fg('#AAAAFF')) self._canvas.drawText(pos=(14,11),text=f"Powered By, pyTermTk") self._canvas.drawText(pos=( 2,14),text=f"https://github.com/ceccopierangiolieugenio/pyTermTk", color=TTkColor.fg('#44FFFF')) diff --git a/ttkDesigner/app/cfg.py b/ttkDesigner/app/cfg.py index 6634164e..1ca202c3 100644 --- a/ttkDesigner/app/cfg.py +++ b/ttkDesigner/app/cfg.py @@ -25,7 +25,7 @@ import os # import yaml -class TTKodeCfg: +class TTkDesignerCfg: version="__VERSION__" name="__NAME__" cfgVersion = '1.0' diff --git a/tutorial/ttkDesigner/textEdit/textEdit.rst b/tutorial/ttkDesigner/textEdit/textEdit.rst new file mode 100644 index 00000000..e69de29b diff --git a/tutorial/ttkDesigner/textEdit/textEdit.tui.json b/tutorial/ttkDesigner/textEdit/textEdit.tui.json new file mode 100644 index 00000000..57b36854 --- /dev/null +++ b/tutorial/ttkDesigner/textEdit/textEdit.tui.json @@ -0,0 +1,536 @@ +{ + "version": "1.0.0", + "tui": { + "class": "TTkWindow", + "params": { + "Name": "WinTextEditor", + "Position": [ + 4, + 2 + ], + "Size": [ + 100, + 38 + ], + "Min Width": 2, + "Min Height": 4, + "Max Width": 4096, + "Max Height": 4096, + "Padding": [ + 3, + 1, + 1, + 1 + ], + "Layout": "TTkGridLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Border": true, + "Title": "\u001b[0m\u001b[0mMr. Text Editor\u001b[0m", + "Window Flags": 134266880 + }, + "layout": { + "class": "TTkGridLayout", + "params": { + "Geometry": [ + 0, + 0, + 98, + 34 + ] + }, + "children": [ + { + "class": "TTkFileButtonPicker", + "params": { + "Name": "BtnSave", + "Position": [ + 6, + 0 + ], + "Size": [ + 6, + 3 + ], + "Min Width": 4, + "Min Height": 3, + "Max Width": 6, + "Max Height": 3, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Layout": "TTkLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Text": "\u001b[0m\u001b[0m\ud83d\udcbe\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false, + "Path": ".", + "Caption": "Save File", + "Filters": "All Files (*)", + "File Mode": 0 + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 6, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 1, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnUndo", + "Position": [ + 18, + 0 + ], + "Size": [ + 16, + 3 + ], + "Min Width": 6, + "Min Height": 3, + "Max Width": 65536, + "Max Height": 65536, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Layout": "TTkLayout", + "Visible": true, + "Enabled": false, + "ToolTip": "\u001b[0m", + "Text": "\u001b[0m\u001b[0mUndo\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 16, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 3, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnRedo", + "Position": [ + 34, + 0 + ], + "Size": [ + 16, + 3 + ], + "Min Width": 6, + "Min Height": 3, + "Max Width": 65536, + "Max Height": 65536, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Layout": "TTkLayout", + "Visible": true, + "Enabled": false, + "ToolTip": "\u001b[0m", + "Text": "\u001b[0m\u001b[0mRedo\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 16, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 4, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnCut", + "Position": [ + 50, + 0 + ], + "Size": [ + 16, + 3 + ], + "Min Width": 5, + "Min Height": 3, + "Max Width": 65536, + "Max Height": 65536, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Layout": "TTkLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Text": "\u001b[0m\u001b[0mCut\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 16, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 5, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnCopy", + "Position": [ + 66, + 0 + ], + "Size": [ + 16, + 3 + ], + "Min Width": 6, + "Min Height": 3, + "Max Width": 65536, + "Max Height": 65536, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Layout": "TTkLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Text": "\u001b[0m\u001b[0mCopy\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 16, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 6, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnPaste", + "Position": [ + 82, + 0 + ], + "Size": [ + 16, + 3 + ], + "Min Width": 7, + "Min Height": 3, + "Max Width": 65536, + "Max Height": 65536, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Layout": "TTkLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Text": "\u001b[0m\u001b[0mPaste\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 16, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 7, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkColorButtonPicker", + "params": { + "Name": "BtnColor", + "Position": [ + 12, + 0 + ], + "Size": [ + 6, + 3 + ], + "Min Width": 2, + "Min Height": 3, + "Max Width": 6, + "Max Height": 65536, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Layout": "TTkLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Text": "\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false, + "Color": "\u001b[48;2;0;0;68m" + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 6, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 2, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkTextEdit", + "params": { + "Name": "TTkTextEdit", + "Position": [ + 0, + 3 + ], + "Size": [ + 98, + 31 + ], + "Min Width": 0, + "Min Height": 0, + "Max Width": 65536, + "Max Height": 65536, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Line Number": true, + "Read Only": false, + "Multi Line": true + }, + "row": 1, + "col": 0, + "rowspan": 1, + "colspan": 8 + }, + { + "class": "TTkFileButtonPicker", + "params": { + "Name": "BtnOpen", + "Position": [ + 0, + 0 + ], + "Size": [ + 6, + 3 + ], + "Min Width": 4, + "Min Height": 3, + "Max Width": 6, + "Max Height": 3, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Layout": "TTkLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Text": "\u001b[0m\u001b[0m\ud83d\udcc2\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false, + "Path": ".", + "Caption": "Open File", + "Filters": "All Files (*);;Txt Files (*.txt);;Python files (*.py)", + "File Mode": 1 + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 6, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 0, + "rowspan": 1, + "colspan": 1 + } + ] + } + }, + "connections": [ + { + "sender": "TTkTextEdit", + "receiver": "BtnUndo", + "signal": "undoAvailable(bool)", + "slot": "setEnabled(bool)" + }, + { + "sender": "TTkTextEdit", + "receiver": "BtnRedo", + "signal": "redoAvailable(bool)", + "slot": "setEnabled(bool)" + }, + { + "sender": "BtnUndo", + "receiver": "TTkTextEdit", + "signal": "clicked()", + "slot": "undo()" + }, + { + "sender": "BtnRedo", + "receiver": "TTkTextEdit", + "signal": "clicked()", + "slot": "redo()" + }, + { + "sender": "BtnCut", + "receiver": "TTkTextEdit", + "signal": "clicked()", + "slot": "cut()" + }, + { + "sender": "BtnCopy", + "receiver": "TTkTextEdit", + "signal": "clicked()", + "slot": "copy()" + }, + { + "sender": "BtnPaste", + "receiver": "TTkTextEdit", + "signal": "clicked()", + "slot": "paste()" + }, + { + "sender": "TTkTextEdit", + "receiver": "BtnColor", + "signal": "currentColorChanged(TTkColor)", + "slot": "setColor(TTkColor)" + }, + { + "sender": "BtnColor", + "receiver": "TTkTextEdit", + "signal": "colorSelected(TTkColor)", + "slot": "setColor(TTkColor)" + }, + { + "sender": "BtnColor", + "receiver": "TTkTextEdit", + "signal": "colorSelected(TTkColor)", + "slot": "setFocus()" + } + ] +} \ No newline at end of file