From 070e175a8aa9e41e6d120b6af6786ac2e67bf154 Mon Sep 17 00:00:00 2001 From: Eugenio Parodi Date: Thu, 27 Apr 2023 23:56:38 +0100 Subject: [PATCH] Added basic ttkDesigner textEdit tutorial --- docs/source/index.rst | 2 + .../ttkDesigner/textEdit/textEdit.01.tui.json | 47 ++ .../ttkDesigner/textEdit/textEdit.02.tui.json | 288 ++++++++++ .../ttkDesigner/textEdit/textEdit.03.tui.json | 322 +++++++++++ .../ttkDesigner/textEdit/textEdit.04.tui.json | 365 ++++++++++++ .../ttkDesigner/textEdit/textEdit.05.tui.json | 520 ++++++++++++++++++ ...textEdit.tui.json => textEdit.06.tui.json} | 242 ++++---- tutorial/ttkDesigner/textEdit/textEdit.rst | 161 ++++++ .../ttkDesigner/textEdit/texteditor.01.py | 20 + .../ttkDesigner/textEdit/texteditor.02.py | 48 ++ ...orial.ttkDesigner.texteditor.breakdown.txt | 27 + 11 files changed, 1922 insertions(+), 120 deletions(-) create mode 100644 tutorial/ttkDesigner/textEdit/textEdit.01.tui.json create mode 100644 tutorial/ttkDesigner/textEdit/textEdit.02.tui.json create mode 100644 tutorial/ttkDesigner/textEdit/textEdit.03.tui.json create mode 100644 tutorial/ttkDesigner/textEdit/textEdit.04.tui.json create mode 100644 tutorial/ttkDesigner/textEdit/textEdit.05.tui.json rename tutorial/ttkDesigner/textEdit/{textEdit.tui.json => textEdit.06.tui.json} (90%) create mode 100755 tutorial/ttkDesigner/textEdit/texteditor.01.py create mode 100755 tutorial/ttkDesigner/textEdit/texteditor.02.py create mode 100644 tutorial/ttkDesigner/textEdit/tutorial.ttkDesigner.texteditor.breakdown.txt diff --git a/docs/source/index.rst b/docs/source/index.rst index 460692a5..2a8a6c1a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -34,6 +34,8 @@ Intro tutorial/004-logging.rst tutorial/005-calculator.rst + tutorial/ttkDesigner/textEdit/textEdit.rst + .. toctree:: :maxdepth: 1 :caption: API Reference diff --git a/tutorial/ttkDesigner/textEdit/textEdit.01.tui.json b/tutorial/ttkDesigner/textEdit/textEdit.01.tui.json new file mode 100644 index 00000000..aaef4fc4 --- /dev/null +++ b/tutorial/ttkDesigner/textEdit/textEdit.01.tui.json @@ -0,0 +1,47 @@ +{ + "version": "1.0.0", + "tui": { + "class": "TTkWindow", + "params": { + "Name": "WinTextEditor", + "Position": [ + 4, + 2 + ], + "Size": [ + 73, + 21 + ], + "Min Width": 2, + "Min Height": 4, + "Max Width": 4098, + "Max Height": 4100, + "Padding": [ + 3, + 1, + 1, + 1 + ], + "Layout": "TTkGridLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Border": true, + "Title": "\u001b[0m\u001b[0mMr Text editor \ud83d\ude0e\u001b[0m", + "Window Flags": 134217728 + }, + "layout": { + "class": "TTkGridLayout", + "params": { + "Geometry": [ + 0, + 0, + 71, + 17 + ] + }, + "children": [] + } + }, + "connections": [] +} \ No newline at end of file diff --git a/tutorial/ttkDesigner/textEdit/textEdit.02.tui.json b/tutorial/ttkDesigner/textEdit/textEdit.02.tui.json new file mode 100644 index 00000000..582e71ec --- /dev/null +++ b/tutorial/ttkDesigner/textEdit/textEdit.02.tui.json @@ -0,0 +1,288 @@ +{ + "version": "1.0.0", + "tui": { + "class": "TTkWindow", + "params": { + "Name": "WinTextEditor", + "Position": [ + 4, + 2 + ], + "Size": [ + 73, + 21 + ], + "Min Width": 2, + "Min Height": 4, + "Max Width": 4098, + "Max Height": 4100, + "Padding": [ + 3, + 1, + 1, + 1 + ], + "Layout": "TTkGridLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Border": true, + "Title": "\u001b[0m\u001b[0mMr Text editor \ud83d\ude0e\u001b[0m", + "Window Flags": 134217728 + }, + "layout": { + "class": "TTkGridLayout", + "params": { + "Geometry": [ + 0, + 0, + 71, + 17 + ] + }, + "children": [ + { + "class": "TTkButton", + "params": { + "Name": "BtnUndo", + "Position": [ + 0, + 0 + ], + "Size": [ + 14, + 17 + ], + "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[0mUndo\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 14, + 17 + ] + }, + "children": [] + }, + "row": 0, + "col": 0, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnRedo", + "Position": [ + 14, + 0 + ], + "Size": [ + 14, + 17 + ], + "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[0mRedo\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 14, + 17 + ] + }, + "children": [] + }, + "row": 0, + "col": 1, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnCut", + "Position": [ + 28, + 0 + ], + "Size": [ + 14, + 17 + ], + "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, + 14, + 17 + ] + }, + "children": [] + }, + "row": 0, + "col": 2, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnCopy", + "Position": [ + 42, + 0 + ], + "Size": [ + 14, + 17 + ], + "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, + 14, + 17 + ] + }, + "children": [] + }, + "row": 0, + "col": 3, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnPaste", + "Position": [ + 56, + 0 + ], + "Size": [ + 15, + 17 + ], + "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, + 15, + 17 + ] + }, + "children": [] + }, + "row": 0, + "col": 4, + "rowspan": 1, + "colspan": 1 + } + ] + } + }, + "connections": [] +} \ No newline at end of file diff --git a/tutorial/ttkDesigner/textEdit/textEdit.03.tui.json b/tutorial/ttkDesigner/textEdit/textEdit.03.tui.json new file mode 100644 index 00000000..1652e534 --- /dev/null +++ b/tutorial/ttkDesigner/textEdit/textEdit.03.tui.json @@ -0,0 +1,322 @@ +{ + "version": "1.0.0", + "tui": { + "class": "TTkWindow", + "params": { + "Name": "WinTextEditor", + "Position": [ + 4, + 2 + ], + "Size": [ + 73, + 21 + ], + "Min Width": 2, + "Min Height": 4, + "Max Width": 4098, + "Max Height": 4100, + "Padding": [ + 3, + 1, + 1, + 1 + ], + "Layout": "TTkGridLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Border": true, + "Title": "\u001b[0m\u001b[0mMr Text editor \ud83d\ude0e\u001b[0m", + "Window Flags": 134217728 + }, + "layout": { + "class": "TTkGridLayout", + "params": { + "Geometry": [ + 0, + 0, + 71, + 17 + ] + }, + "children": [ + { + "class": "TTkButton", + "params": { + "Name": "BtnUndo", + "Position": [ + 0, + 0 + ], + "Size": [ + 14, + 3 + ], + "Min Width": 6, + "Min Height": 3, + "Max Width": 65536, + "Max Height": 3, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Layout": "TTkLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Text": "\u001b[0m\u001b[0mUndo\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 14, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 1, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnRedo", + "Position": [ + 14, + 0 + ], + "Size": [ + 14, + 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[0mRedo\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 14, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 2, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnCut", + "Position": [ + 28, + 0 + ], + "Size": [ + 14, + 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, + 14, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 3, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnCopy", + "Position": [ + 42, + 0 + ], + "Size": [ + 14, + 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, + 14, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 4, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnPaste", + "Position": [ + 56, + 0 + ], + "Size": [ + 15, + 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, + 15, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 5, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkTextEdit", + "params": { + "Name": "TextEdit", + "Position": [ + 0, + 3 + ], + "Size": [ + 71, + 14 + ], + "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": 1, + "rowspan": 1, + "colspan": 5 + } + ] + } + }, + "connections": [] +} \ No newline at end of file diff --git a/tutorial/ttkDesigner/textEdit/textEdit.04.tui.json b/tutorial/ttkDesigner/textEdit/textEdit.04.tui.json new file mode 100644 index 00000000..65c0d85c --- /dev/null +++ b/tutorial/ttkDesigner/textEdit/textEdit.04.tui.json @@ -0,0 +1,365 @@ +{ + "version": "1.0.0", + "tui": { + "class": "TTkWindow", + "params": { + "Name": "WinTextEditor", + "Position": [ + 4, + 2 + ], + "Size": [ + 73, + 21 + ], + "Min Width": 2, + "Min Height": 4, + "Max Width": 4098, + "Max Height": 4100, + "Padding": [ + 3, + 1, + 1, + 1 + ], + "Layout": "TTkGridLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Border": true, + "Title": "\u001b[0m\u001b[0mMr Text editor \ud83d\ude0e\u001b[0m", + "Window Flags": 134217728 + }, + "layout": { + "class": "TTkGridLayout", + "params": { + "Geometry": [ + 0, + 0, + 71, + 17 + ] + }, + "children": [ + { + "class": "TTkButton", + "params": { + "Name": "BtnUndo", + "Position": [ + 0, + 0 + ], + "Size": [ + 14, + 3 + ], + "Min Width": 6, + "Min Height": 3, + "Max Width": 65536, + "Max Height": 3, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Layout": "TTkLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Text": "\u001b[0m\u001b[0mUndo\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 14, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 1, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnRedo", + "Position": [ + 14, + 0 + ], + "Size": [ + 14, + 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[0mRedo\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 14, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 2, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnCut", + "Position": [ + 28, + 0 + ], + "Size": [ + 14, + 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, + 14, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 3, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnCopy", + "Position": [ + 42, + 0 + ], + "Size": [ + 14, + 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, + 14, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 4, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnPaste", + "Position": [ + 56, + 0 + ], + "Size": [ + 15, + 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, + 15, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 5, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkTextEdit", + "params": { + "Name": "TextEdit", + "Position": [ + 0, + 3 + ], + "Size": [ + 71, + 14 + ], + "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": 1, + "rowspan": 1, + "colspan": 5 + } + ] + } + }, + "connections": [ + { + "sender": "TextEdit", + "receiver": "BtnUndo", + "signal": "undoAvailable(bool)", + "slot": "setEnabled(bool)" + }, + { + "sender": "TextEdit", + "receiver": "BtnRedo", + "signal": "redoAvailable(bool)", + "slot": "setEnabled(bool)" + }, + { + "sender": "BtnUndo", + "receiver": "TextEdit", + "signal": "clicked()", + "slot": "undo()" + }, + { + "sender": "BtnRedo", + "receiver": "TextEdit", + "signal": "clicked()", + "slot": "redo()" + }, + { + "sender": "BtnCut", + "receiver": "TextEdit", + "signal": "clicked()", + "slot": "cut()" + }, + { + "sender": "BtnCopy", + "receiver": "TextEdit", + "signal": "clicked()", + "slot": "copy()" + }, + { + "sender": "BtnPaste", + "receiver": "TextEdit", + "signal": "clicked()", + "slot": "paste()" + } + ] +} \ No newline at end of file diff --git a/tutorial/ttkDesigner/textEdit/textEdit.05.tui.json b/tutorial/ttkDesigner/textEdit/textEdit.05.tui.json new file mode 100644 index 00000000..0b47d74c --- /dev/null +++ b/tutorial/ttkDesigner/textEdit/textEdit.05.tui.json @@ -0,0 +1,520 @@ +{ + "version": "1.0.0", + "tui": { + "class": "TTkWindow", + "params": { + "Name": "WinTextEditor", + "Position": [ + 4, + 2 + ], + "Size": [ + 73, + 21 + ], + "Min Width": 2, + "Min Height": 4, + "Max Width": 4098, + "Max Height": 4100, + "Padding": [ + 3, + 1, + 1, + 1 + ], + "Layout": "TTkGridLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Border": true, + "Title": "\u001b[0m\u001b[0mMr Text editor \ud83d\ude0e\u001b[0m", + "Window Flags": 134217728 + }, + "layout": { + "class": "TTkGridLayout", + "params": { + "Geometry": [ + 0, + 0, + 71, + 17 + ] + }, + "children": [ + { + "class": "TTkButton", + "params": { + "Name": "BtnUndo", + "Position": [ + 18, + 0 + ], + "Size": [ + 10, + 3 + ], + "Min Width": 6, + "Min Height": 3, + "Max Width": 65536, + "Max Height": 3, + "Padding": [ + 0, + 0, + 0, + 0 + ], + "Layout": "TTkLayout", + "Visible": true, + "Enabled": true, + "ToolTip": "\u001b[0m", + "Text": "\u001b[0m\u001b[0mUndo\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 10, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 3, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnRedo", + "Position": [ + 28, + 0 + ], + "Size": [ + 11, + 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[0mRedo\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 11, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 4, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnCut", + "Position": [ + 39, + 0 + ], + "Size": [ + 10, + 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, + 10, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 5, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnCopy", + "Position": [ + 49, + 0 + ], + "Size": [ + 11, + 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, + 11, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 6, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkButton", + "params": { + "Name": "BtnPaste", + "Position": [ + 60, + 0 + ], + "Size": [ + 11, + 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, + 11, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 7, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkFileButtonPicker", + "params": { + "Name": "BtnOpen", + "Position": [ + 0, + 0 + ], + "Size": [ + 6, + 3 + ], + "Min Width": 4, + "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\u001b[0m\ud83d\udcc2\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false, + "Path": ".", + "Caption": "File Dialog", + "Filters": "All Files (*)", + "Accept Mode": 0, + "File Mode": 1 + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 6, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 0, + "rowspan": 1, + "colspan": 1 + }, + { + "class": "TTkFileButtonPicker", + "params": { + "Name": "BtnSave", + "Position": [ + 6, + 0 + ], + "Size": [ + 6, + 3 + ], + "Min Width": 4, + "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\u001b[0m\ud83d\udcbe\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false, + "Path": ".", + "Caption": "File Dialog", + "Filters": "All Files (*)", + "Accept Mode": 1, + "File Mode": 0 + }, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 6, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 1, + "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": "TextEdit", + "Position": [ + 0, + 3 + ], + "Size": [ + 71, + 14 + ], + "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 + } + ] + } + }, + "connections": [ + { + "sender": "TextEdit", + "receiver": "BtnUndo", + "signal": "undoAvailable(bool)", + "slot": "setEnabled(bool)" + }, + { + "sender": "TextEdit", + "receiver": "BtnRedo", + "signal": "redoAvailable(bool)", + "slot": "setEnabled(bool)" + }, + { + "sender": "BtnUndo", + "receiver": "TextEdit", + "signal": "clicked()", + "slot": "undo()" + }, + { + "sender": "BtnRedo", + "receiver": "TextEdit", + "signal": "clicked()", + "slot": "redo()" + }, + { + "sender": "BtnCut", + "receiver": "TextEdit", + "signal": "clicked()", + "slot": "cut()" + }, + { + "sender": "BtnCopy", + "receiver": "TextEdit", + "signal": "clicked()", + "slot": "copy()" + }, + { + "sender": "BtnPaste", + "receiver": "TextEdit", + "signal": "clicked()", + "slot": "paste()" + } + ] +} \ No newline at end of file diff --git a/tutorial/ttkDesigner/textEdit/textEdit.tui.json b/tutorial/ttkDesigner/textEdit/textEdit.06.tui.json similarity index 90% rename from tutorial/ttkDesigner/textEdit/textEdit.tui.json rename to tutorial/ttkDesigner/textEdit/textEdit.06.tui.json index 57b36854..bbeaf860 100644 --- a/tutorial/ttkDesigner/textEdit/textEdit.tui.json +++ b/tutorial/ttkDesigner/textEdit/textEdit.06.tui.json @@ -9,13 +9,13 @@ 2 ], "Size": [ - 100, - 38 + 73, + 21 ], "Min Width": 2, "Min Height": 4, - "Max Width": 4096, - "Max Height": 4096, + "Max Width": 4098, + "Max Height": 4100, "Padding": [ 3, 1, @@ -27,8 +27,8 @@ "Enabled": true, "ToolTip": "\u001b[0m", "Border": true, - "Title": "\u001b[0m\u001b[0mMr. Text Editor\u001b[0m", - "Window Flags": 134266880 + "Title": "\u001b[0m\u001b[0mMr Text editor \ud83d\ude0e\u001b[0m", + "Window Flags": 134217728 }, "layout": { "class": "TTkGridLayout", @@ -36,63 +36,11 @@ "Geometry": [ 0, 0, - 98, - 34 + 71, + 17 ] }, "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": { @@ -102,13 +50,13 @@ 0 ], "Size": [ - 16, + 10, 3 ], "Min Width": 6, "Min Height": 3, "Max Width": 65536, - "Max Height": 65536, + "Max Height": 3, "Padding": [ 0, 0, @@ -117,7 +65,7 @@ ], "Layout": "TTkLayout", "Visible": true, - "Enabled": false, + "Enabled": true, "ToolTip": "\u001b[0m", "Text": "\u001b[0m\u001b[0mUndo\u001b[0m", "Border": true, @@ -130,7 +78,7 @@ "Geometry": [ 0, 0, - 16, + 10, 3 ] }, @@ -146,11 +94,11 @@ "params": { "Name": "BtnRedo", "Position": [ - 34, + 28, 0 ], "Size": [ - 16, + 11, 3 ], "Min Width": 6, @@ -165,7 +113,7 @@ ], "Layout": "TTkLayout", "Visible": true, - "Enabled": false, + "Enabled": true, "ToolTip": "\u001b[0m", "Text": "\u001b[0m\u001b[0mRedo\u001b[0m", "Border": true, @@ -178,7 +126,7 @@ "Geometry": [ 0, 0, - 16, + 11, 3 ] }, @@ -194,11 +142,11 @@ "params": { "Name": "BtnCut", "Position": [ - 50, + 39, 0 ], "Size": [ - 16, + 10, 3 ], "Min Width": 5, @@ -226,7 +174,7 @@ "Geometry": [ 0, 0, - 16, + 10, 3 ] }, @@ -242,11 +190,11 @@ "params": { "Name": "BtnCopy", "Position": [ - 66, + 49, 0 ], "Size": [ - 16, + 11, 3 ], "Min Width": 6, @@ -274,7 +222,7 @@ "Geometry": [ 0, 0, - 16, + 11, 3 ] }, @@ -290,11 +238,11 @@ "params": { "Name": "BtnPaste", "Position": [ - 82, + 60, 0 ], "Size": [ - 16, + 11, 3 ], "Min Width": 7, @@ -322,7 +270,7 @@ "Geometry": [ 0, 0, - 16, + 11, 3 ] }, @@ -334,18 +282,18 @@ "colspan": 1 }, { - "class": "TTkColorButtonPicker", + "class": "TTkFileButtonPicker", "params": { - "Name": "BtnColor", + "Name": "BtnOpen", "Position": [ - 12, + 0, 0 ], "Size": [ 6, 3 ], - "Min Width": 2, + "Min Width": 4, "Min Height": 3, "Max Width": 6, "Max Height": 65536, @@ -359,11 +307,15 @@ "Visible": true, "Enabled": true, "ToolTip": "\u001b[0m", - "Text": "\u001b[0m", + "Text": "\u001b[0m\u001b[0m\ud83d\udcc2\u001b[0m", "Border": true, "Checkable": false, "Checked": false, - "Color": "\u001b[48;2;0;0;68m" + "Path": ".", + "Caption": "File Dialog", + "Filters": "All Files (*)", + "Accept Mode": 0, + "File Mode": 1 }, "layout": { "class": "TTkLayout", @@ -378,25 +330,25 @@ "children": [] }, "row": 0, - "col": 2, + "col": 0, "rowspan": 1, "colspan": 1 }, { - "class": "TTkTextEdit", + "class": "TTkFileButtonPicker", "params": { - "Name": "TTkTextEdit", + "Name": "BtnSave", "Position": [ - 0, - 3 + 6, + 0 ], "Size": [ - 98, - 31 + 6, + 3 ], - "Min Width": 0, - "Min Height": 0, - "Max Width": 65536, + "Min Width": 4, + "Min Height": 3, + "Max Width": 6, "Max Height": 65536, "Padding": [ 0, @@ -404,34 +356,53 @@ 0, 0 ], + "Layout": "TTkLayout", "Visible": true, "Enabled": true, "ToolTip": "\u001b[0m", - "Line Number": true, - "Read Only": false, - "Multi Line": true + "Text": "\u001b[0m\u001b[0m\ud83d\udcbe\u001b[0m", + "Border": true, + "Checkable": false, + "Checked": false, + "Path": ".", + "Caption": "File Dialog", + "Filters": "All Files (*)", + "Accept Mode": 1, + "File Mode": 0 }, - "row": 1, - "col": 0, + "layout": { + "class": "TTkLayout", + "params": { + "Geometry": [ + 0, + 0, + 6, + 3 + ] + }, + "children": [] + }, + "row": 0, + "col": 1, "rowspan": 1, - "colspan": 8 + "colspan": 1 }, { - "class": "TTkFileButtonPicker", + "class": "TTkColorButtonPicker", "params": { - "Name": "BtnOpen", + "Name": "BtnColor", "Position": [ - 0, + 12, 0 ], "Size": [ 6, 3 ], - "Min Width": 4, + "Min Width": 2, "Min Height": 3, "Max Width": 6, - "Max Height": 3, + "Max Height": 65536, "Padding": [ 0, 0, @@ -442,14 +413,11 @@ "Visible": true, "Enabled": true, "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0m\ud83d\udcc2\u001b[0m", + "Text": "\u001b[0m", "Border": true, "Checkable": false, "Checked": false, - "Path": ".", - "Caption": "Open File", - "Filters": "All Files (*);;Txt Files (*.txt);;Python files (*.py)", - "File Mode": 1 + "Color": "\u001b[48;2;0;0;68m" }, "layout": { "class": "TTkLayout", @@ -464,71 +432,105 @@ "children": [] }, "row": 0, - "col": 0, + "col": 2, "rowspan": 1, "colspan": 1 + }, + { + "class": "TTkTextEdit", + "params": { + "Name": "TextEdit", + "Position": [ + 0, + 3 + ], + "Size": [ + 71, + 14 + ], + "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 } ] } }, "connections": [ { - "sender": "TTkTextEdit", + "sender": "TextEdit", "receiver": "BtnUndo", "signal": "undoAvailable(bool)", "slot": "setEnabled(bool)" }, { - "sender": "TTkTextEdit", + "sender": "TextEdit", "receiver": "BtnRedo", "signal": "redoAvailable(bool)", "slot": "setEnabled(bool)" }, { "sender": "BtnUndo", - "receiver": "TTkTextEdit", + "receiver": "TextEdit", "signal": "clicked()", "slot": "undo()" }, { "sender": "BtnRedo", - "receiver": "TTkTextEdit", + "receiver": "TextEdit", "signal": "clicked()", "slot": "redo()" }, { "sender": "BtnCut", - "receiver": "TTkTextEdit", + "receiver": "TextEdit", "signal": "clicked()", "slot": "cut()" }, { "sender": "BtnCopy", - "receiver": "TTkTextEdit", + "receiver": "TextEdit", "signal": "clicked()", "slot": "copy()" }, { "sender": "BtnPaste", - "receiver": "TTkTextEdit", + "receiver": "TextEdit", "signal": "clicked()", "slot": "paste()" }, { - "sender": "TTkTextEdit", + "sender": "TextEdit", "receiver": "BtnColor", "signal": "currentColorChanged(TTkColor)", "slot": "setColor(TTkColor)" }, { "sender": "BtnColor", - "receiver": "TTkTextEdit", + "receiver": "TextEdit", "signal": "colorSelected(TTkColor)", "slot": "setColor(TTkColor)" }, { "sender": "BtnColor", - "receiver": "TTkTextEdit", + "receiver": "TextEdit", "signal": "colorSelected(TTkColor)", "slot": "setFocus()" } diff --git a/tutorial/ttkDesigner/textEdit/textEdit.rst b/tutorial/ttkDesigner/textEdit/textEdit.rst index e69de29b..b01cabd5 100644 --- a/tutorial/ttkDesigner/textEdit/textEdit.rst +++ b/tutorial/ttkDesigner/textEdit/textEdit.rst @@ -0,0 +1,161 @@ +.. _pyTermTk: https://github.com/ceccopierangiolieugenio/pyTermTk +.. _TermTk: https://github.com/ceccopierangiolieugenio/pyTermTk +.. _ttkDesigner: https://github.com/ceccopierangiolieugenio/pyTermTk/tree/main/ttkDesigner + +=================== +ttkDesigner_ - Your first TextEditor +=================== + + +Start a new project +=================== + +.. raw:: html + + + +`textEdit.01.tui.json `_ + +.. code:: bash + + # You can quickly open this file using: + ttkDesigner tutorial/ttkDesigner/textEdit/textEdit.01.tui.json + + + +Add The first buttons (Undo,redo - Cut,Copy,Paste) +================================================== + +.. raw:: html + + + +`textEdit.02.tui.json `_ + + + +Add the TextEdit widget +======================= + +.. raw:: html + + + +`textEdit.03.tui.json `_ + + + +Link the Events/Slots for the basic functionalities +=================================================== + +.. raw:: html + + + +`textEdit.04.tui.json `_ + + + +Add few extra controls (Open/Save/Color) +======================================== + +I used those emoji as file open/save text 📂 💾 + +.. raw:: html + + + +`textEdit.05.tui.json `_ + + + +Link the Events/Slots for the color feature +=========================================== + +.. raw:: html + + + +`textEdit.06.tui.json `_ + + + +Preview and Quick Export +======================== + +.. raw:: html + + + +Exported: `texteditor.01.py `_ +(`Try Online `__) + +.. code:: bash + + # If you want to try without installation, run from the pyTermTk root folder + PYTHONPATH=`pwd` python3 tutorial/ttkDesigner/textEdit/texteditor.01.py + + +Imclude the Open/Save routine +------------------------------- + +Once (quick)exported the code, we need to define the appropriate routines and link them to the file(open/save) pickers `signals `__ + +`texteditor.02.py `_ +(`Try Online `__) + +.. code:: bash + + # If you want to try without installation, run from the pyTermTk root folder + PYTHONPATH=`pwd` python3 tutorial/ttkDesigner/textEdit/texteditor.02.py + + +.. code:: python + + # Retrieve the widgets we need to use + btnOpen = textEditWindow.getWidgetByName("BtnOpen") + btnSave = textEditWindow.getWidgetByName("BtnSave") + textEdit = textEditWindow.getWidgetByName("TextEdit") + + + # This is a generic routine to open/read a file + # and push the content to the "TextEdit" widget + pyTTkSlot(str) + def openRoutine(fileName): + with open(fileName) as fp: + textEdit.setText(fp.read()) + + # Connect the open routine to the (open)"filePicked" event + btnOpen.filePicked.connect(openRoutine) + + + # This is a generic routine to save the content of + # the "TextEdit" widget to the chosen file + pyTTkSlot(str) + def saveRoutine(fileName): + with open(fileName, 'w') as fp: + fp.write(textEdit.toPlainText()) + + # Connect the save routine to the (save)"filePicked" event + btnSave.filePicked.connect(saveRoutine) diff --git a/tutorial/ttkDesigner/textEdit/texteditor.01.py b/tutorial/ttkDesigner/textEdit/texteditor.01.py new file mode 100755 index 00000000..9bae5d7f --- /dev/null +++ b/tutorial/ttkDesigner/textEdit/texteditor.01.py @@ -0,0 +1,20 @@ +from TermTk import TTkUtil, TTkUiLoader, TTk + +# Data generated using ttkDesigner +widget = TTkUiLoader.loadDict(TTkUtil.base64_deflate_2_obj( + "eJytVltvG0UUXtvrXV96yYVSICBWCKkOEpaDUAlqXhLTGNi6tRJDhao8bHZHPqOud63d2dAgVUI8OdWIBxgU3ipA8MAv4Inf1J/Amdn1NQmKq3pleWe+M2e+75vL8ff6" + + "L99UNPV5KmrcPCJRTMNA8OJGvVFvCF5gCRUSKrq+E8eCl7vdxw9p4IXfCm4MnMjpxwrX7zt9IvhVxLrkCbvrURZGgpc6YUyZTHkgarZu5wnX9+l3RDW/sG8QXm7TwHpI" + + "PQbCzvOKbH1OaA+YsHUEnScZ2M4vIYrNDG3rS9zsOJ5Hg57KVrBz8iHcuOcchwlDMsi1FVFv1Da/pjE99IkYcvNu4OCbJ1+7Yeh36UBwfe1Ro4+ydsLIIxFCxS5lGM4t" + + "CchvO7KkOosoeZb14vmvP6aDrqSmWLu+04vFl2hoKeGGn86MBkERXgfzKTrSImGfsOgYKWv4tOxlJmJecoH6XkSUUSpeWb2TMIbmyZE1KHNzhwVf4TwCqlLyiq0RuCrf" + + "KnaBwHXbgCW7AMs4fU6DFXxdPcim0WToDZUzswNuDuGNIbwJb3FdihJ8aSRTTqFkwdqQl5tA3MfSLXHCTdVA304SeDeV9aEkB++l0yAPVAPvH4iEFyLcJLbGC27oC7vA" + + "TWzHAycQdo6b2Je9J2maW9Ma98hY49tjjdXzNKY/czKR01gc1Ce6ZNqRLmicwMYFKqoTFXDb1uATW4dNOwefnmVrINumdFORvTW/IMWFyV4fkcWsl+FaOcO1eBFX6Wwz" + + "HBxnZDdeobMy7cs5a1zEtoRsO07MSEZ3a56uuTDd5RFdlffl+JqzfPkqnqhd6pP0pHYono5o5rw+GOChTiVoYwlGKkFPJaAJi9n94vnPP8zS53rHwVuS5+p4zzWdgbpz" + + "eVUysz6jjh/2sB9bDG94vBm3fd+SWGzVPljHuG3XJQNmtUOPyCNbVuPSVu58Z4wzzmhzK9mbdmHfORotpPHqXPjp31kXIIAQBrOyIZqXCwx5JrZ2WWG5uSV/DZe8Gfph" + + "dO6al9QpQzSTe2Vebn4hufgdr3ExzcuvrT36ePPOR3ca+Nze7IvLCsnPCamikFG1nvCf9GSbtpDxb9nXJH8N+Wv/e+4mlaV6jwbEup/0D1VBLe8Rx7MeBP4x1pJKO/EZ" + + "tWSEGEqKualNVEpIkvCqGwYBceVmjrPCyI2YBLI8wykvRcQl9Eg21rGf9gLHF3w1wfK1feRQXxat2iGWd9zieuyHssbFhGW1P0OUF7/BKfwOW/AHX43I2dHwJ/yVxa1j" + + "3CnGlV1frrtXkyg35Jy1cbKtNAj+lpBMOIFaU1DRTdgE2Zse5OKFOoEOpiBzIC+v2gzxZ0joHTeJ8P8DU3ukCU7QQ3KjnapIrqB21ZrqzpI8y1TddGX3PvHR9MWHwz8Y" + + "VsGw3dBNYkmRJPX/AFIIXtE=")) + +root=TTk() +root.layout().addWidget(widget) +root.mainloop() diff --git a/tutorial/ttkDesigner/textEdit/texteditor.02.py b/tutorial/ttkDesigner/textEdit/texteditor.02.py new file mode 100755 index 00000000..f52d0402 --- /dev/null +++ b/tutorial/ttkDesigner/textEdit/texteditor.02.py @@ -0,0 +1,48 @@ +from TermTk import TTkUtil, TTkUiLoader, TTk +from TermTk import pyTTkSlot + +# Data generated using ttkDesigner +# "textEditWindow" is the object defined using ttkDesigner +textEditWindow = TTkUiLoader.loadDict(TTkUtil.base64_deflate_2_obj( + "eJytVltvG0UUXtvrXV96yYVSICBWCKkOEpaDUAlqXhLTGNi6tRJDhao8bHZHPqOud63d2dAgVUI8OdWIBxgU3ipA8MAv4Inf1J/Amdn1NQmKq3pleWe+M2e+75vL8ff6" + + "L99UNPV5KmrcPCJRTMNA8OJGvVFvCF5gCRUSKrq+E8eCl7vdxw9p4IXfCm4MnMjpxwrX7zt9IvhVxLrkCbvrURZGgpc6YUyZTHkgarZu5wnX9+l3RDW/sG8QXm7TwHpI" + + "PQbCzvOKbH1OaA+YsHUEnScZ2M4vIYrNDG3rS9zsOJ5Hg57KVrBz8iHcuOcchwlDMsi1FVFv1Da/pjE99IkYcvNu4OCbJ1+7Yeh36UBwfe1Ro4+ydsLIIxFCxS5lGM4t" + + "CchvO7KkOosoeZb14vmvP6aDrqSmWLu+04vFl2hoKeGGn86MBkERXgfzKTrSImGfsOgYKWv4tOxlJmJecoH6XkSUUSpeWb2TMIbmyZE1KHNzhwVf4TwCqlLyiq0RuCrf" + + "KnaBwHXbgCW7AMs4fU6DFXxdPcim0WToDZUzswNuDuGNIbwJb3FdihJ8aSRTTqFkwdqQl5tA3MfSLXHCTdVA304SeDeV9aEkB++l0yAPVAPvH4iEFyLcJLbGC27oC7vA" + + "TWzHAycQdo6b2Je9J2maW9Ma98hY49tjjdXzNKY/czKR01gc1Ce6ZNqRLmicwMYFKqoTFXDb1uATW4dNOwefnmVrINumdFORvTW/IMWFyV4fkcWsl+FaOcO1eBFX6Wwz" + + "HBxnZDdeobMy7cs5a1zEtoRsO07MSEZ3a56uuTDd5RFdlffl+JqzfPkqnqhd6pP0pHYono5o5rw+GOChTiVoYwlGKkFPJaAJi9n94vnPP8zS53rHwVuS5+p4zzWdgbpz" + + "eVUysz6jjh/2sB9bDG94vBm3fd+SWGzVPljHuG3XJQNmtUOPyCNbVuPSVu58Z4wzzmhzK9mbdmHfORotpPHqXPjp31kXIIAQBrOyIZqXCwx5JrZ2WWG5uSV/DZe8Gfph" + + "dO6al9QpQzSTe2Vebn4hufgdr3ExzcuvrT36ePPOR3ca+Nze7IvLCsnPCamikFG1nvCf9GSbtpDxb9nXJH8N+Wv/e+4mlaV6jwbEup/0D1VBLe8Rx7MeBP4x1pJKO/EZ" + + "tWSEGEqKualNVEpIkvCqGwYBceVmjrPCyI2YBLI8wykvRcQl9Eg21rGf9gLHF3w1wfK1feRQXxat2iGWd9zieuyHssbFhGW1P0OUF7/BKfwOW/AHX43I2dHwJ/yVxa1j" + + "3CnGlV1frrtXkyg35Jy1cbKtNAj+lpBMOIFaU1DRTdgE2Zse5OKFOoEOpiBzIC+v2gzxZ0joHTeJ8P8DU3ukCU7QQ3KjnapIrqB21ZrqzpI8y1TddGX3PvHR9MWHwz8Y" + + "VsGw3dBNYkmRJPX/AFIIXtE=")) + +# Retrieve the widgets that we need to use +btnOpen = textEditWindow.getWidgetByName("BtnOpen") +btnSave = textEditWindow.getWidgetByName("BtnSave") +textEdit = textEditWindow.getWidgetByName("TextEdit") + +# This is a generic routine to open/read a file +# and push the content to the "TextEdit" widget +pyTTkSlot(str) +def openRoutine(fileName): + with open(fileName) as fp: + textEdit.setText(fp.read()) + +# Connect the open routine to the (open)"filePicked" event +btnOpen.filePicked.connect(openRoutine) + +# This is a generic routine to save the content of +# the "TextEdit" widget to the chosen file +pyTTkSlot(str) +def saveRoutine(fileName): + with open(fileName, 'w') as fp: + fp.write(textEdit.toPlainText()) + +# Connect the save routine to the (save)"filePicked" event +btnSave.filePicked.connect(saveRoutine) + +# Initialize TTK, add the window widget, and start the main loop +root=TTk() +root.layout().addWidget(textEditWindow) +root.mainloop() diff --git a/tutorial/ttkDesigner/textEdit/tutorial.ttkDesigner.texteditor.breakdown.txt b/tutorial/ttkDesigner/textEdit/tutorial.ttkDesigner.texteditor.breakdown.txt new file mode 100644 index 00000000..cbadc33b --- /dev/null +++ b/tutorial/ttkDesigner/textEdit/tutorial.ttkDesigner.texteditor.breakdown.txt @@ -0,0 +1,27 @@ + + - 01 - New Window , Rename (Mr. Text Editor), Set name (WinTextEditor), Set GridLayout + + - 02 - Add Buttons , (Undo,Redo - Cut,Copy,Paste), Set Name (BtnUndo, . . .) + + - 03 - Add TextEdit, set Max height of Undo + + - 04 - Add events and Test + • [ TTkTextEdit ^]│[undoAvailable(bo^]│[ BtnUndo ^]│[setEnabled(bool)^]│ + • [ TTkTextEdit ^]│[redoAvailable(bo^]│[ BtnRedo ^]│[setEnabled(bool)^]│ + • [ BtnUndo ^]│[ clicked() ^]│[ TTkTextEdit ^]│[ undo() ^]│ + • [ BtnRedo ^]│[ clicked() ^]│[ TTkTextEdit ^]│[ redo() ^]│ + + • [ BtnCut ^]│[ clicked() ^]│[ TTkTextEdit ^]│[ cut() ^]│ + • [ BtnCopy ^]│[ clicked() ^]│[ TTkTextEdit ^]│[ copy() ^]│ + • [ BtnPaste ^]│[ clicked() ^]│[ TTkTextEdit ^]│[ paste() ^]│ + + - 05 - Add Buttons , (Load Save Color) and reshape layout + + - 06 - Add events and test + • [ TTkTextEdit ^]│[currentColorChan^]│[ BtnColor ^]│[setColor(TTkColo^]│ + • [ BtnColor ^]│[colorSelected(TT^]│[ TTkTextEdit ^]│[setColor(TTkColo^]│ + • [ BtnColor ^]│[colorSelected(TT^]│[ TTkTextEdit ^]│[ setFocus() ^]│ + + - 07 - Quick Export + +