Browse Source

Added basic ttkDesigner textEdit tutorial

pull/137/head
Eugenio Parodi 3 years ago
parent
commit
070e175a8a
  1. 2
      docs/source/index.rst
  2. 47
      tutorial/ttkDesigner/textEdit/textEdit.01.tui.json
  3. 288
      tutorial/ttkDesigner/textEdit/textEdit.02.tui.json
  4. 322
      tutorial/ttkDesigner/textEdit/textEdit.03.tui.json
  5. 365
      tutorial/ttkDesigner/textEdit/textEdit.04.tui.json
  6. 520
      tutorial/ttkDesigner/textEdit/textEdit.05.tui.json
  7. 242
      tutorial/ttkDesigner/textEdit/textEdit.06.tui.json
  8. 161
      tutorial/ttkDesigner/textEdit/textEdit.rst
  9. 20
      tutorial/ttkDesigner/textEdit/texteditor.01.py
  10. 48
      tutorial/ttkDesigner/textEdit/texteditor.02.py
  11. 27
      tutorial/ttkDesigner/textEdit/tutorial.ttkDesigner.texteditor.breakdown.txt

2
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

47
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": []
}

288
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": []
}

322
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": []
}

365
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()"
}
]
}

520
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()"
}
]
}

242
tutorial/ttkDesigner/textEdit/textEdit.tui.json → 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()"
}

161
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
<video width="800"
src="https://user-images.githubusercontent.com/8876552/234842682-1ecd40dd-6829-47ff-bfb7-eae397553879.webm"
data-canonical-src="https://user-images.githubusercontent.com/8876552/234842682-1ecd40dd-6829-47ff-bfb7-eae397553879.webm"
controls="controls" muted="muted" class="d-block rounded-bottom-2 border-top width-fit" ></video>
`textEdit.01.tui.json <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/ttkDesigner/textEdit/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
<video width="800"
src="https://user-images.githubusercontent.com/8876552/234842705-0252d988-047f-46a1-8241-7a4e710c3791.webm"
data-canonical-src="https://user-images.githubusercontent.com/8876552/234842705-0252d988-047f-46a1-8241-7a4e710c3791.webm"
controls="controls" muted="muted" class="d-block rounded-bottom-2 border-top width-fit" ></video>
`textEdit.02.tui.json <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/ttkDesigner/textEdit/textEdit.02.tui.json>`_
Add the TextEdit widget
=======================
.. raw:: html
<video width="800"
src="https://user-images.githubusercontent.com/8876552/234842721-f9ae924e-0047-4ce3-b1e6-3e0c7d27cb38.webm"
data-canonical-src="https://user-images.githubusercontent.com/8876552/234842721-f9ae924e-0047-4ce3-b1e6-3e0c7d27cb38.webm"
controls="controls" muted="muted" class="d-block rounded-bottom-2 border-top width-fit" ></video>
`textEdit.03.tui.json <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/ttkDesigner/textEdit/textEdit.03.tui.json>`_
Link the Events/Slots for the basic functionalities
===================================================
.. raw:: html
<video width="800"
src="https://user-images.githubusercontent.com/8876552/234842736-fdf73508-2ef1-419e-9b30-6d262a0ff514.webm"
data-canonical-src="https://user-images.githubusercontent.com/8876552/234842736-fdf73508-2ef1-419e-9b30-6d262a0ff514.webm"
controls="controls" muted="muted" class="d-block rounded-bottom-2 border-top width-fit" ></video>
`textEdit.04.tui.json <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/ttkDesigner/textEdit/textEdit.04.tui.json>`_
Add few extra controls (Open/Save/Color)
========================================
I used those emoji as file open/save text 📂 💾
.. raw:: html
<video width="800"
src="https://user-images.githubusercontent.com/8876552/234842758-dbd647ba-2596-4ec8-9a76-135435504505.webm"
data-canonical-src="https://user-images.githubusercontent.com/8876552/234842758-dbd647ba-2596-4ec8-9a76-135435504505.webm"
controls="controls" muted="muted" class="d-block rounded-bottom-2 border-top width-fit" ></video>
`textEdit.05.tui.json <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/ttkDesigner/textEdit/textEdit.05.tui.json>`_
Link the Events/Slots for the color feature
===========================================
.. raw:: html
<video width="800"
src="https://user-images.githubusercontent.com/8876552/234842774-cf8c3fc3-4bb7-45ff-8e04-30a93aa343c6.webm"
data-canonical-src="https://user-images.githubusercontent.com/8876552/234842774-cf8c3fc3-4bb7-45ff-8e04-30a93aa343c6.webm"
controls="controls" muted="muted" class="d-block rounded-bottom-2 border-top width-fit" ></video>
`textEdit.06.tui.json <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/ttkDesigner/textEdit/textEdit.06.tui.json>`_
Preview and Quick Export
========================
.. raw:: html
<video width="800"
src="https://user-images.githubusercontent.com/8876552/234842788-208e271a-e0b1-44f6-94b4-a62db00fd45a.webm"
data-canonical-src="https://user-images.githubusercontent.com/8876552/234842788-208e271a-e0b1-44f6-94b4-a62db00fd45a.webm"
controls="controls" muted="muted" class="d-block rounded-bottom-2 border-top width-fit" ></video>
Exported: `texteditor.01.py <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/ttkDesigner/textEdit/texteditor.01.py>`_
(`Try Online <https://ceccopierangiolieugenio.github.io/pyTermTk/sandbox/sandbox.html?fileUri=https://raw.githubusercontent.com/ceccopierangiolieugenio/pyTermTk/main/tutorial/ttkDesigner/textEdit/texteditor.01.py>`__)
.. 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 <https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.TTkPickers.filepicker.html#TermTk.TTkWidgets.TTkPickers.filepicker.TTkFileButtonPicker.filePicked>`__
`texteditor.02.py <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/ttkDesigner/textEdit/texteditor.02.py>`_
(`Try Online <https://ceccopierangiolieugenio.github.io/pyTermTk/sandbox/sandbox.html?fileUri=https://raw.githubusercontent.com/ceccopierangiolieugenio/pyTermTk/main/tutorial/ttkDesigner/textEdit/texteditor.02.py>`__)
.. 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)

20
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()

48
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()

27
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
Loading…
Cancel
Save