From 94eb43ae5ee12a76d422e305436a992f7bda6423 Mon Sep 17 00:00:00 2001 From: Eugenio Parodi Date: Sun, 2 May 2021 15:47:37 +0100 Subject: [PATCH] Doc Updated --- _images/Signal.Slots.001.svg | 3 + .../TTkAbstract/abstractscrollarea.html | 19 +- .../TTkAbstract/abstractscrollview.html | 19 +- _modules/TermTk/TTkCore/canvas.html | 19 +- _modules/TermTk/TTkCore/constant.html | 19 +- _modules/TermTk/TTkCore/signal.html | 23 +- _modules/TermTk/TTkCore/timer.html | 19 +- _modules/TermTk/TTkCore/ttk.html | 29 +- _modules/TermTk/TTkGui/theme.html | 22 +- _modules/TermTk/TTkLayouts/boxlayout.html | 29 +- _modules/TermTk/TTkLayouts/gridlayout.html | 24 +- _modules/TermTk/TTkLayouts/layout.html | 31 +- _modules/TermTk/TTkTestWidgets/logviewer.html | 19 +- .../TermTk/TTkTestWidgets/testwidget.html | 19 +- .../TTkTestWidgets/testwidgetsizes.html | 19 +- .../TTkWidgets/TTkPickers/colorpicker.html | 24 +- _modules/TermTk/TTkWidgets/button.html | 19 +- _modules/TermTk/TTkWidgets/checkbox.html | 19 +- _modules/TermTk/TTkWidgets/combobox.html | 19 +- _modules/TermTk/TTkWidgets/frame.html | 19 +- _modules/TermTk/TTkWidgets/graph.html | 21 +- _modules/TermTk/TTkWidgets/label.html | 19 +- _modules/TermTk/TTkWidgets/lineedit.html | 19 +- _modules/TermTk/TTkWidgets/list.html | 19 +- _modules/TermTk/TTkWidgets/listwidget.html | 19 +- _modules/TermTk/TTkWidgets/menubar.html | 19 +- _modules/TermTk/TTkWidgets/radiobutton.html | 19 +- .../TermTk/TTkWidgets/resizableframe.html | 19 +- _modules/TermTk/TTkWidgets/scrollarea.html | 19 +- _modules/TermTk/TTkWidgets/scrollbar.html | 19 +- _modules/TermTk/TTkWidgets/spacer.html | 19 +- _modules/TermTk/TTkWidgets/spinbox.html | 19 +- _modules/TermTk/TTkWidgets/splitter.html | 19 +- _modules/TermTk/TTkWidgets/table.html | 19 +- _modules/TermTk/TTkWidgets/tableview.html | 19 +- _modules/TermTk/TTkWidgets/tabwidget.html | 19 +- _modules/TermTk/TTkWidgets/texedit.html | 19 +- _modules/TermTk/TTkWidgets/tree.html | 19 +- _modules/TermTk/TTkWidgets/treeview.html | 19 +- _modules/TermTk/TTkWidgets/treewidget.html | 19 +- _modules/TermTk/TTkWidgets/widget.html | 20 +- _modules/TermTk/TTkWidgets/window.html | 19 +- _modules/TermTk/libbpytop/term.html | 19 +- _modules/index.html | 19 +- _sources/autogen.TermTk/TermTk.rst.txt | 4 +- _sources/index.rst.txt | 39 +- _sources/tutorial/001-helloworld.rst.txt | 78 ++++ _sources/tutorial/002-layout.rst.txt | 391 ++++++++++++++++++ _sources/tutorial/003-signalslots.rst.txt | 157 +++++++ _sources/tutorial/004-logging.rst.txt | 139 +++++++ _static/theme_overrides.css | 15 +- .../TermTk.TTkAbstract.abstractitemmodel.html | 38 +- ...TermTk.TTkAbstract.abstractscrollarea.html | 40 +- ...TermTk.TTkAbstract.abstractscrollview.html | 40 +- autogen.TermTk/TermTk.TTkAbstract.html | 42 +- autogen.TermTk/TermTk.TTkCore.canvas.html | 56 +-- autogen.TermTk/TermTk.TTkCore.cfg.html | 54 +-- autogen.TermTk/TermTk.TTkCore.color.html | 54 +-- autogen.TermTk/TermTk.TTkCore.constant.html | 58 +-- autogen.TermTk/TermTk.TTkCore.draw.html | 54 +-- autogen.TermTk/TermTk.TTkCore.filebuffer.html | 54 +-- autogen.TermTk/TermTk.TTkCore.helper.html | 54 +-- autogen.TermTk/TermTk.TTkCore.html | 54 +-- autogen.TermTk/TermTk.TTkCore.log.html | 54 +-- autogen.TermTk/TermTk.TTkCore.signal.html | 64 +-- autogen.TermTk/TermTk.TTkCore.timer.html | 56 +-- autogen.TermTk/TermTk.TTkCore.ttk.html | 70 ++-- autogen.TermTk/TermTk.TTkGui.html | 34 +- autogen.TermTk/TermTk.TTkGui.theme.html | 99 +++-- .../TermTk.TTkLayouts.boxlayout.html | 51 ++- .../TermTk.TTkLayouts.gridlayout.html | 47 ++- autogen.TermTk/TermTk.TTkLayouts.html | 46 +-- autogen.TermTk/TermTk.TTkLayouts.layout.html | 57 +-- autogen.TermTk/TermTk.TTkTemplates.color.html | 40 +- autogen.TermTk/TermTk.TTkTemplates.html | 40 +- .../TermTk.TTkTemplates.keyevents.html | 40 +- .../TermTk.TTkTemplates.mouseevents.html | 40 +- autogen.TermTk/TermTk.TTkTemplates.text.html | 40 +- autogen.TermTk/TermTk.TTkTestWidgets.html | 38 +- .../TermTk.TTkTestWidgets.logviewer.html | 40 +- .../TermTk.TTkTestWidgets.testwidget.html | 40 +- ...TermTk.TTkTestWidgets.testwidgetsizes.html | 40 +- autogen.TermTk/TermTk.TTkTypes.html | 36 +- .../TermTk.TTkTypes.treewidgetitem.html | 36 +- autogen.TermTk/TermTk.TTkTypes.viewitem.html | 36 +- ...mTk.TTkWidgets.TTkPickers.colorpicker.html | 102 ++--- .../TermTk.TTkWidgets.TTkPickers.html | 90 ++-- autogen.TermTk/TermTk.TTkWidgets.button.html | 90 ++-- .../TermTk.TTkWidgets.checkbox.html | 90 ++-- .../TermTk.TTkWidgets.combobox.html | 90 ++-- .../TermTk.TTkWidgets.filetree.html | 88 ++-- autogen.TermTk/TermTk.TTkWidgets.frame.html | 90 ++-- autogen.TermTk/TermTk.TTkWidgets.graph.html | 90 ++-- autogen.TermTk/TermTk.TTkWidgets.html | 88 ++-- autogen.TermTk/TermTk.TTkWidgets.label.html | 90 ++-- .../TermTk.TTkWidgets.lineedit.html | 90 ++-- autogen.TermTk/TermTk.TTkWidgets.list.html | 90 ++-- .../TermTk.TTkWidgets.listwidget.html | 92 +++-- autogen.TermTk/TermTk.TTkWidgets.menubar.html | 90 ++-- .../TermTk.TTkWidgets.radiobutton.html | 90 ++-- .../TermTk.TTkWidgets.resizableframe.html | 90 ++-- .../TermTk.TTkWidgets.scrollarea.html | 90 ++-- .../TermTk.TTkWidgets.scrollbar.html | 90 ++-- autogen.TermTk/TermTk.TTkWidgets.spacer.html | 90 ++-- autogen.TermTk/TermTk.TTkWidgets.spinbox.html | 90 ++-- .../TermTk.TTkWidgets.splitter.html | 90 ++-- autogen.TermTk/TermTk.TTkWidgets.table.html | 90 ++-- .../TermTk.TTkWidgets.tableview.html | 90 ++-- .../TermTk.TTkWidgets.tabwidget.html | 90 ++-- autogen.TermTk/TermTk.TTkWidgets.texedit.html | 90 ++-- autogen.TermTk/TermTk.TTkWidgets.tree.html | 90 ++-- .../TermTk.TTkWidgets.treeview.html | 90 ++-- .../TermTk.TTkWidgets.treewidget.html | 90 ++-- autogen.TermTk/TermTk.TTkWidgets.widget.html | 99 ++--- autogen.TermTk/TermTk.TTkWidgets.window.html | 92 ++--- autogen.TermTk/TermTk.html | 44 +- autogen.TermTk/TermTk.libbpytop.colors.html | 40 +- autogen.TermTk/TermTk.libbpytop.html | 44 +- autogen.TermTk/TermTk.libbpytop.input.html | 40 +- autogen.TermTk/TermTk.libbpytop.inputkey.html | 40 +- autogen.TermTk/TermTk.libbpytop.term.html | 48 ++- genindex.html | 30 +- index.html | 58 ++- objects.inv | Bin 4659 -> 5155 bytes py-modindex.html | 19 +- search.html | 19 +- searchindex.js | 2 +- 127 files changed, 4075 insertions(+), 2367 deletions(-) create mode 100644 _images/Signal.Slots.001.svg create mode 100644 _sources/tutorial/001-helloworld.rst.txt create mode 100644 _sources/tutorial/002-layout.rst.txt create mode 100644 _sources/tutorial/003-signalslots.rst.txt create mode 100644 _sources/tutorial/004-logging.rst.txt diff --git a/_images/Signal.Slots.001.svg b/_images/Signal.Slots.001.svg new file mode 100644 index 00000000..23b8c1a9 --- /dev/null +++ b/_images/Signal.Slots.001.svg @@ -0,0 +1,3 @@ + + +Object 1Signal_1 (int) Signal_2 (str)Signal_3 (str, int)Slot_1 (int, str)Object 3Signal_1 (int, str)Slot_1 (str, int)
Obj2.Signal_1.connect(Obj4.Slot_1)
Obj4.Signal_1.connect(Obj2.Slot_2)
Obj2.Signal_1.connect(Obj4.Slot_1)...
Object 4Signal_1 (int) Slot_1 (str, str)Slot_2 (str, int)Object 2Signal_1 (str, str)Slot_2 (int)Slot_1 (str)
Obj1.Signal_1.connect(Obj2.Slot_2)
Obj1.Signal_1.connect(Obj2.Slot_2)
Obj1.Signal_2.connect(Obj2.Slot_1)
Obj1.Signal_2.connect(Obj2.Slot_1)
Obj3.Signal_1.connect(Obj1.Slot_1)
Obj3.Signal_1.connect(Obj1.Slot_1)
%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22Obj1.Signal_2.connect(Obj2.Slot_1)%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22257.58790272353417%22%20y%3D%2288.00000000000011%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22Obj1.Signal_2.connect(Obj2.Slot_1)%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22257.58790272353417%22%20y%3D%2288.00000000000011%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E
%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22Obj1.Signal_2.connect(Obj2.Slot_1)%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22257.58790272353417%22%20y%3D%2288.00000000000011%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22Obj1.Signal_2.connect(Obj2.Slot_1)%22%20style%3D%22edgeLabel%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3Bresizable%3D0%3Bpoints%3D%5B%5D%3B%22%20vertex%3D%221%22%20connectable%3D%220%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22257.58790272353417%22%20y%3D%2288.00000000000011%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E
Obj1.Signal_3.connect(Obj3.Slot_1)
Obj1.Signal_3.connect(Obj4.Slot_2)
Obj1.Signal_3.connect(Obj3.Slot_1)...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/_modules/TermTk/TTkAbstract/abstractscrollarea.html b/_modules/TermTk/TTkAbstract/abstractscrollarea.html index 7c7acdba..de3c85a9 100644 --- a/_modules/TermTk/TTkAbstract/abstractscrollarea.html +++ b/_modules/TermTk/TTkAbstract/abstractscrollarea.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkAbstract/abstractscrollview.html b/_modules/TermTk/TTkAbstract/abstractscrollview.html index 4e5845e0..fe8ffee0 100644 --- a/_modules/TermTk/TTkAbstract/abstractscrollview.html +++ b/_modules/TermTk/TTkAbstract/abstractscrollview.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkCore/canvas.html b/_modules/TermTk/TTkCore/canvas.html index 56a3bf1a..09d238b2 100644 --- a/_modules/TermTk/TTkCore/canvas.html +++ b/_modules/TermTk/TTkCore/canvas.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkCore/constant.html b/_modules/TermTk/TTkCore/constant.html index 012ac751..cf95277e 100644 --- a/_modules/TermTk/TTkCore/constant.html +++ b/_modules/TermTk/TTkCore/constant.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkCore/signal.html b/_modules/TermTk/TTkCore/signal.html index b67842c4..4bc1e2c2 100644 --- a/_modules/TermTk/TTkCore/signal.html +++ b/_modules/TermTk/TTkCore/signal.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ @@ -182,7 +197,7 @@ ''' Signals & Slots [`Tutorial <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/003-signalslots.md>`_] -========================= +========================================================================================================================= Signals and slots are used for communication between objects. @@ -203,7 +218,7 @@ | A slot is a function that is called in response to a particular signal. | `TermTk <https://github.com/ceccopierangiolieugenio/pyTermTk>`_'s :mod:`~TermTk.TTkWidgets` have many predefined signals/slots, but it is possible to subclass any :mod:`~TermTk.TTkWidgets` and add our own signals/slots to them. -.. image:: /../_static/Signal.Slots.001.svg +.. image:: /_static/Signal.Slots.001.svg Methods ======= diff --git a/_modules/TermTk/TTkCore/timer.html b/_modules/TermTk/TTkCore/timer.html index fbfc6a36..21dfae62 100644 --- a/_modules/TermTk/TTkCore/timer.html +++ b/_modules/TermTk/TTkCore/timer.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkCore/ttk.html b/_modules/TermTk/TTkCore/ttk.html index 9dc435a7..e8edc021 100644 --- a/_modules/TermTk/TTkCore/ttk.html +++ b/_modules/TermTk/TTkCore/ttk.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ @@ -227,7 +242,8 @@ self.frame = 0 self.time = curtime - def mainloop(self): +
[docs] def mainloop(self): + '''Enters the main event loop and waits until :meth:`~quit` is called or the main widget is destroyed.''' TTkLog.debug( "" ) TTkLog.debug( " ████████╗ ████████╗ " ) TTkLog.debug( " ╚══██╔══╝ ╚══██╔══╝ " ) @@ -317,7 +333,7 @@ else: TTkLog.error(f"Unhandled Event {evt}") break - lbt.Term.exit() + lbt.Term.exit()
def _time_event(self): self.events.put(TTkK.TIME_EVENT) @@ -342,10 +358,11 @@ def _canvas_thread(self): pass - def quit(self): +
[docs] def quit(self): + '''Tells the application to exit with a return code.''' self.events.put(TTkK.QUIT_EVENT) TTkTimer.quitAll() - self.running = False + self.running = False
def _SIGSTOP(self, signum, frame): """Reset terminal settings and stop background input read before putting to sleep""" diff --git a/_modules/TermTk/TTkGui/theme.html b/_modules/TermTk/TTkGui/theme.html index 392436e9..a42e42d8 100644 --- a/_modules/TermTk/TTkGui/theme.html +++ b/_modules/TermTk/TTkGui/theme.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ @@ -181,6 +196,7 @@
[docs]class TTkTheme(): ''' from: https://en.wikipedia.org/wiki/Box-drawing_character + :: ┌─┬┐ ╔═╦╗ ╓─╥╖ ╒═╤╕ │ ││ ║ ║║ ║ ║║ │ ││ @@ -238,6 +254,7 @@ (), # TODO: Grid 10 ) ''' Grid Types + :: grid0 grid1 grid2 grid3 ┌─┬┐ ╔═╦╗ ╔═╤╗ ┌─╥┐ @@ -297,6 +314,7 @@ '◀','▶' ) ''' Tab Examples + :: ┌──────╔══════╗──────┬──────┐ ┌─┌──────╔══════╗──────┬──────┐─┐ │Label1║Label2║Label3│Label4│ │◀│Label1║Label2║Label3│Label4│▶│ diff --git a/_modules/TermTk/TTkLayouts/boxlayout.html b/_modules/TermTk/TTkLayouts/boxlayout.html index ef260922..30af6412 100644 --- a/_modules/TermTk/TTkLayouts/boxlayout.html +++ b/_modules/TermTk/TTkLayouts/boxlayout.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ @@ -185,7 +200,9 @@
[docs]class TTkHBoxLayout(TTkGridLayout): ''' The TTkHBoxLayout class lines up widgets horizontally - ```text + + :: + TTkHBoxLayout ╔═════════╤═════════╤═════════╗ ║ Widget1 │ Widget2 │ Widget3 ║ @@ -195,13 +212,14 @@ ║ │ │ ║ ║ │ │ ║ ╚═════════╧═════════╧═════════╝ - ``` ''' pass
[docs]class TTkVBoxLayout(TTkGridLayout): ''' The TTkVBoxLayout class lines up widgets vertically - ```text + + :: + TTkVBoxLayout ╔═════════════════════════════╗ ║ Widget 1 ║ @@ -212,7 +230,6 @@ ╟─────────────────────────────╢ ║ Widget 4 ║ ╚═════════════════════════════╝ - ``` '''
[docs] def addItem(self, item): TTkGridLayout.addItem(self, item, self.count(), 0)
diff --git a/_modules/TermTk/TTkLayouts/gridlayout.html b/_modules/TermTk/TTkLayouts/gridlayout.html index 4d94dca8..c642f7bf 100644 --- a/_modules/TermTk/TTkLayouts/gridlayout.html +++ b/_modules/TermTk/TTkLayouts/gridlayout.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ @@ -189,7 +204,8 @@ The grid layout allows an automatic place all the widgets in a grid, <br/> the empty rows/cols are resized to the "columnMinHeight,columnMinWidth" parameters - ``` + :: + TTkGridLayout ┌┐ columnMinWidth ╔═════════╤═════════╤╤═════════╗ ║ Widget1 │ Widget2 ││ Widget3 ║ @@ -202,7 +218,7 @@ ║ │ ││ Widget5 ║ ║ │ ││ (3,3) ║ ╚═════════╧═════════╧╧═════════╝ - ``` + :param int columnMinWidth: the minimum width of the column, optional, defaults to 0 :param int columnMinHeight: the minimum height of the column, optional, defaults to 0 ''' diff --git a/_modules/TermTk/TTkLayouts/layout.html b/_modules/TermTk/TTkLayouts/layout.html index c5cf433a..c262dbf5 100644 --- a/_modules/TermTk/TTkLayouts/layout.html +++ b/_modules/TermTk/TTkLayouts/layout.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ @@ -266,10 +281,13 @@
[docs]class TTkLayout(TTkLayoutItem): - ''' The :class:`TTkLayout` class is the base class of geometry managers. <br/> - It allows free placement of the widgets in the layout area. <br/> - Used mainly to have free range moving :class:`~TermTk.TTkWidgets.window.TTkWindow` because the widgets are not automatically rearranged after a layout event - ``` + ''' + | The :class:`TTkLayout` class is the base class of geometry managers. <br/> + | It allows free placement of the widgets in the layout area. <br/> + | Used mainly to have free range moving :class:`~TermTk.TTkWidgets.window.TTkWindow` because the widgets are not automatically rearranged after a layout event + + :: + ╔════════════════════════════╗ ║ pos(4,2) ║ ║ ┌───────┐ pos(16,4) ║ @@ -280,7 +298,6 @@ ║ └───────┘ ║ ║ ║ ╚════════════════════════════╝ - ``` ''' __slots__ = ('_items', '_zSortedItems', '_parent') def __init__(self, *args, **kwargs): diff --git a/_modules/TermTk/TTkTestWidgets/logviewer.html b/_modules/TermTk/TTkTestWidgets/logviewer.html index 3c8f0f69..37dcb87b 100644 --- a/_modules/TermTk/TTkTestWidgets/logviewer.html +++ b/_modules/TermTk/TTkTestWidgets/logviewer.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkTestWidgets/testwidget.html b/_modules/TermTk/TTkTestWidgets/testwidget.html index 7c5cb70d..7781fa79 100644 --- a/_modules/TermTk/TTkTestWidgets/testwidget.html +++ b/_modules/TermTk/TTkTestWidgets/testwidget.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkTestWidgets/testwidgetsizes.html b/_modules/TermTk/TTkTestWidgets/testwidgetsizes.html index 3f95e322..27af9f2a 100644 --- a/_modules/TermTk/TTkTestWidgets/testwidgetsizes.html +++ b/_modules/TermTk/TTkTestWidgets/testwidgetsizes.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/TTkPickers/colorpicker.html b/_modules/TermTk/TTkWidgets/TTkPickers/colorpicker.html index f3492241..515969fc 100644 --- a/_modules/TermTk/TTkWidgets/TTkPickers/colorpicker.html +++ b/_modules/TermTk/TTkWidgets/TTkPickers/colorpicker.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ @@ -351,8 +366,9 @@ self.colorClicked.emit(self._textColor)
[docs]class TTkColorDialogPicker(TTkWindow,TColor): - ''' - ### Color Picker Layout sizes: + ''' Color Picker Layout sizes: + + :: Terminal window (More or less, It is too annoying to redraw this) ┌────────────────────────────────────────────────┐ │┌──────[Palette]───────┐┌────[Color]───────────┐│ diff --git a/_modules/TermTk/TTkWidgets/button.html b/_modules/TermTk/TTkWidgets/button.html index eb9d58d1..d781d6a1 100644 --- a/_modules/TermTk/TTkWidgets/button.html +++ b/_modules/TermTk/TTkWidgets/button.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/checkbox.html b/_modules/TermTk/TTkWidgets/checkbox.html index fed8a27e..4e112760 100644 --- a/_modules/TermTk/TTkWidgets/checkbox.html +++ b/_modules/TermTk/TTkWidgets/checkbox.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/combobox.html b/_modules/TermTk/TTkWidgets/combobox.html index 80a00839..997932e5 100644 --- a/_modules/TermTk/TTkWidgets/combobox.html +++ b/_modules/TermTk/TTkWidgets/combobox.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/frame.html b/_modules/TermTk/TTkWidgets/frame.html index a2283c28..8cba83a2 100644 --- a/_modules/TermTk/TTkWidgets/frame.html +++ b/_modules/TermTk/TTkWidgets/frame.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/graph.html b/_modules/TermTk/TTkWidgets/graph.html index bdba2ae2..d89bf64c 100644 --- a/_modules/TermTk/TTkWidgets/graph.html +++ b/_modules/TermTk/TTkWidgets/graph.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ @@ -217,6 +232,8 @@ i=0 data = self._data[-w*2:] # TTkLog.debug(data) + # TODO: use deep unpacking technique to grab couples of values + # https://mathspp.com/blog/pydonts/enumerate-me#deep-unpacking mv = max(max(map(max,data)),-min(map(min,data))) zoom = 2*h/mv if mv>0 else 1.0 for i in range(len(data)): diff --git a/_modules/TermTk/TTkWidgets/label.html b/_modules/TermTk/TTkWidgets/label.html index 40804916..ed97d8ee 100644 --- a/_modules/TermTk/TTkWidgets/label.html +++ b/_modules/TermTk/TTkWidgets/label.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/lineedit.html b/_modules/TermTk/TTkWidgets/lineedit.html index c93bcce8..65ffe874 100644 --- a/_modules/TermTk/TTkWidgets/lineedit.html +++ b/_modules/TermTk/TTkWidgets/lineedit.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/list.html b/_modules/TermTk/TTkWidgets/list.html index 210d5e89..37d60141 100644 --- a/_modules/TermTk/TTkWidgets/list.html +++ b/_modules/TermTk/TTkWidgets/list.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/listwidget.html b/_modules/TermTk/TTkWidgets/listwidget.html index 966548ab..d5d5ba58 100644 --- a/_modules/TermTk/TTkWidgets/listwidget.html +++ b/_modules/TermTk/TTkWidgets/listwidget.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/menubar.html b/_modules/TermTk/TTkWidgets/menubar.html index e8761eba..86079dd0 100644 --- a/_modules/TermTk/TTkWidgets/menubar.html +++ b/_modules/TermTk/TTkWidgets/menubar.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/radiobutton.html b/_modules/TermTk/TTkWidgets/radiobutton.html index 7c4647f0..32d0aefb 100644 --- a/_modules/TermTk/TTkWidgets/radiobutton.html +++ b/_modules/TermTk/TTkWidgets/radiobutton.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/resizableframe.html b/_modules/TermTk/TTkWidgets/resizableframe.html index ebc2b9a5..a81376aa 100644 --- a/_modules/TermTk/TTkWidgets/resizableframe.html +++ b/_modules/TermTk/TTkWidgets/resizableframe.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/scrollarea.html b/_modules/TermTk/TTkWidgets/scrollarea.html index a25c4f50..49e9af03 100644 --- a/_modules/TermTk/TTkWidgets/scrollarea.html +++ b/_modules/TermTk/TTkWidgets/scrollarea.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/scrollbar.html b/_modules/TermTk/TTkWidgets/scrollbar.html index 08d54b14..706ed867 100644 --- a/_modules/TermTk/TTkWidgets/scrollbar.html +++ b/_modules/TermTk/TTkWidgets/scrollbar.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/spacer.html b/_modules/TermTk/TTkWidgets/spacer.html index 8ad61396..75f32101 100644 --- a/_modules/TermTk/TTkWidgets/spacer.html +++ b/_modules/TermTk/TTkWidgets/spacer.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/spinbox.html b/_modules/TermTk/TTkWidgets/spinbox.html index efbd2243..8c73b934 100644 --- a/_modules/TermTk/TTkWidgets/spinbox.html +++ b/_modules/TermTk/TTkWidgets/spinbox.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/splitter.html b/_modules/TermTk/TTkWidgets/splitter.html index 85879b33..3f6a1925 100644 --- a/_modules/TermTk/TTkWidgets/splitter.html +++ b/_modules/TermTk/TTkWidgets/splitter.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/table.html b/_modules/TermTk/TTkWidgets/table.html index 388c1ab3..f80543f0 100644 --- a/_modules/TermTk/TTkWidgets/table.html +++ b/_modules/TermTk/TTkWidgets/table.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/tableview.html b/_modules/TermTk/TTkWidgets/tableview.html index eaabcb50..490c158c 100644 --- a/_modules/TermTk/TTkWidgets/tableview.html +++ b/_modules/TermTk/TTkWidgets/tableview.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/tabwidget.html b/_modules/TermTk/TTkWidgets/tabwidget.html index fa67cbd2..8a2d2f9f 100644 --- a/_modules/TermTk/TTkWidgets/tabwidget.html +++ b/_modules/TermTk/TTkWidgets/tabwidget.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/texedit.html b/_modules/TermTk/TTkWidgets/texedit.html index 044646ec..a3cea3fa 100644 --- a/_modules/TermTk/TTkWidgets/texedit.html +++ b/_modules/TermTk/TTkWidgets/texedit.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/tree.html b/_modules/TermTk/TTkWidgets/tree.html index 3242cc5d..752fc3c2 100644 --- a/_modules/TermTk/TTkWidgets/tree.html +++ b/_modules/TermTk/TTkWidgets/tree.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/treeview.html b/_modules/TermTk/TTkWidgets/treeview.html index a4bd49ad..7c9e3d42 100644 --- a/_modules/TermTk/TTkWidgets/treeview.html +++ b/_modules/TermTk/TTkWidgets/treeview.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/treewidget.html b/_modules/TermTk/TTkWidgets/treewidget.html index 56fc041b..9b0d234d 100644 --- a/_modules/TermTk/TTkWidgets/treewidget.html +++ b/_modules/TermTk/TTkWidgets/treewidget.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/TTkWidgets/widget.html b/_modules/TermTk/TTkWidgets/widget.html index 2a50b42d..c42885cb 100644 --- a/_modules/TermTk/TTkWidgets/widget.html +++ b/_modules/TermTk/TTkWidgets/widget.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ @@ -190,6 +205,7 @@
[docs]class TTkWidget(TMouseEvents,TKeyEvents): ''' Widget Layout sizes: + :: Terminal area (i.e. XTerm) ┌─────────────────────────────────────────┐ diff --git a/_modules/TermTk/TTkWidgets/window.html b/_modules/TermTk/TTkWidgets/window.html index aa8d0bdc..155bb0e5 100644 --- a/_modules/TermTk/TTkWidgets/window.html +++ b/_modules/TermTk/TTkWidgets/window.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/TermTk/libbpytop/term.html b/_modules/TermTk/libbpytop/term.html index 14398b32..743ae6e9 100644 --- a/_modules/TermTk/libbpytop/term.html +++ b/_modules/TermTk/libbpytop/term.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_modules/index.html b/_modules/index.html index b2b987e7..ef128c1c 100644 --- a/_modules/index.html +++ b/_modules/index.html @@ -83,9 +83,24 @@ -

Contents:

+

Tutorials

+

API Reference

+ diff --git a/_sources/autogen.TermTk/TermTk.rst.txt b/_sources/autogen.TermTk/TermTk.rst.txt index 10fbf1fb..c12cdf63 100644 --- a/_sources/autogen.TermTk/TermTk.rst.txt +++ b/_sources/autogen.TermTk/TermTk.rst.txt @@ -1,6 +1,6 @@ -API Reference -~~~~~~~~~~~~~ +TermTk +~~~~~~ .. automodule:: TermTk diff --git a/_sources/index.rst.txt b/_sources/index.rst.txt index e26505f5..cf9b339d 100644 --- a/_sources/index.rst.txt +++ b/_sources/index.rst.txt @@ -3,14 +3,47 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. +.. _pyTermTk: https://github.com/ceccopierangiolieugenio/pyTermTk +.. _TermTk: https://github.com/ceccopierangiolieugenio/pyTermTk +.. _TUI: https://en.wikipedia.org/wiki/Text-based_user_interface +.. _pyCuT: https://github.com/ceccopierangiolieugenio/pyCuT +.. _Qt5: https://www.riverbankcomputing.com/static/Docs/PyQt5/ +.. _GTK: https://pygobject.readthedocs.io/en/latest/ +.. _tkinter: https://docs.python.org/3/library/tkinter.html + Welcome to pyTermTk's documentation! ==================================== +Intro +----- + +pyTermTk_ is a Text-based user interface library (TUI_) +Evolved from the discontinued project pyCuT_ and inspired by a mix of Qt5_, GTK_, and tkinter_ api definition with a touch of personal interpretation + + .. toctree:: - :maxdepth: 2 - :caption: Contents: + :maxdepth: 1 + :caption: Tutorials + + tutorial/001-helloworld.rst + tutorial/002-layout.rst + tutorial/003-signalslots.rst + tutorial/004-logging.rst + +.. toctree:: + :maxdepth: 1 + :caption: API Reference + + autogen.TermTk/TermTk.libbpytop.rst + autogen.TermTk/TermTk.TTkAbstract.rst + autogen.TermTk/TermTk.TTkCore.rst + autogen.TermTk/TermTk.TTkGui.rst + autogen.TermTk/TermTk.TTkLayouts.rst + autogen.TermTk/TermTk.TTkTemplates.rst + autogen.TermTk/TermTk.TTkTestWidgets.rst + autogen.TermTk/TermTk.TTkTypes.rst + autogen.TermTk/TermTk.TTkWidgets.rst - autogen.TermTk/TermTk.rst Indices and tables ================== diff --git a/_sources/tutorial/001-helloworld.rst.txt b/_sources/tutorial/001-helloworld.rst.txt new file mode 100644 index 00000000..45688426 --- /dev/null +++ b/_sources/tutorial/001-helloworld.rst.txt @@ -0,0 +1,78 @@ +.. _pyTermTk: https://github.com/ceccopierangiolieugenio/pyTermTk +.. _TTk: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkCore.ttk.html#TermTk.TTkCore.ttk.TTk +.. _mainloop(): https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkCore.ttk.html#TermTk.TTkCore.ttk.TTk.mainloop +.. _TTkLabel: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.label.html#TermTk.TTkWidgets.label.TTkLabel + +============================================================================= +pyTermTk_ - Hello World +============================================================================= + +Intro +===== + +Creating a simple GUI application using pyTermTk_ involves the following steps: + + - Import TermTk package. + - Create an TTk_ object. + - Add a TTkLabel_ object in it with the caption "**hello world**" in the position (x=5,y=2). + - Enter the mainloop of application by `mainloop()`_ method. + +Examples +======== + +Example 1 +--------- + +Following is the code to execute `helloworld.001.py `_ in pyTermTk_: + +.. code:: python + + import TermTk as ttk + + root = ttk.TTk() + ttk.TTkLabel(parent=root, pos=(5,2), text="Hello World") + root.mainloop() + +The above code produces the following output + +:: + + Hello World + +Example 2 - Your first Window +----------------------------- + +Following is the code to execute `helloworld.002.py `_ in pyTermTk_: + +.. code:: python + + import TermTk as ttk + + # Create a root object (it is a widget that represent the terminal) + root = ttk.TTk() + + # Create a window and attach it to the root (parent=root) + helloWin = ttk.TTkWindow(parent=root,pos = (1,1), size=(30,10), title="Hello Window", border=True) + + # Define the Label and attach it to the window (parent=helloWin) + ttk.TTkLabel(parent=helloWin, pos=(5,5), text="Hello World") + + # Start the Main loop + root.mainloop() + + +The above code produces the following output (yuhuuuuu!!!) + +:: + + ╔════════════════════════════╗ + ║ Hello Window ║ + ╟────────────────────────────╢ + ║ ║ + ║ ║ + ║ Hello World ║ + ║ ║ + ║ ║ + ║ ║ + ╚════════════════════════════╝ + diff --git a/_sources/tutorial/002-layout.rst.txt b/_sources/tutorial/002-layout.rst.txt new file mode 100644 index 00000000..354e1787 --- /dev/null +++ b/_sources/tutorial/002-layout.rst.txt @@ -0,0 +1,391 @@ +.. _pyTermTk: https://github.com/ceccopierangiolieugenio/pyTermTk +.. _windows: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkWidgets/window.html +.. _TTkLabel: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.label.html#TermTk.TTkWidgets.label.TTkLabel +.. _TTkLayouts: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/index.html +.. _TTkLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/layout.html#TermTk.TTkLayouts.layout.TTkLayout +.. _TTkHBoxLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/boxlayout.html#TermTk.TTkLayouts.boxlayout.TTkHBoxLayout +.. _TTkVBoxLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/boxlayout.html#TermTk.TTkLayouts.boxlayout.TTkVBoxLayout +.. _TTkGridLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/gridlayout.html#TermTk.TTkLayouts.gridlayout.TTkGridLayout + +.. _Layout Example: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example1.simple.layout.py +.. _VBox Example: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example2.simple.vbox.py +.. _HBox Example: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example3.simple.hbox.py +.. _Grid Example: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example4.simple.grid.py +.. _Nested Layouts Example: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example5.nested.layouts.py +.. _`row/colspan Example`: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example6.grid.span.py + +============================================================================= +pyTermTk_ - Layouts +============================================================================= + +Intro +===== + +TTkLayouts_ are specialised classes that allow the placement of the widgets. + +TTkLayout_ +---------- + +| This is the base class for all the different layouts. +| It allows free placement of the widgets in the layout area. +| Used mainly to have free range moving windows_ because the widgets are not automatically replaced after a layout event + +:: + + TTkLayout + ╔════════════════════════════╗ + ║ pos(4,2) ║ + ║ ┌───────┐ pos(16,4) ║ + ║ │Widget1│ ┌─────────┐ ║ + ║ │ │ │ Widget2 │ ║ + ║ │ │ └─────────┘ ║ + ║ │ │ ║ + ║ └───────┘ ║ + ║ ║ + ╚════════════════════════════╝ + + +TTkHBoxLayout_ +-------------- + +This layout allow an automatic place all the widgets horizontally + +:: + + TTkHBoxLayout + ╔═════════╤═════════╤═════════╗ + ║ Widget1 │ Widget2 │ Widget3 ║ + ║ │ │ ║ + ║ │ │ ║ + ║ │ │ ║ + ║ │ │ ║ + ║ │ │ ║ + ╚═════════╧═════════╧═════════╝ + + +TTkVBoxLayout_ +-------------- + +This layout allow an automatic place all the widgets vertically + +:: + + TTkVBoxLayout + ╔═════════════════════════════╗ + ║ Widget 1 ║ + ╟─────────────────────────────╢ + ║ Widget 2 ║ + ╟─────────────────────────────╢ + ║ Widget 3 ║ + ╟─────────────────────────────╢ + ║ Widget 4 ║ + ╚═════════════════════════════╝ + + +TTkGridLayout_ +-------------- + +This layout allow an automatic place all the widgets in a grid the empty rows/cols are resized to the "columnMinHeight,columnMinWidth" parameters + +:: + + TTkGridLayout ┌┐ columnMinWidth + ╔═════════╤═════════╤╤═════════╗ + ║ Widget1 │ Widget2 ││ Widget3 ║ + ║ (0,0) │ (0,1) ││ (0,3) ║ + ╟─────────┼─────────┼┼─────────╢ ┐ columnMinHeight + ╟─────────┼─────────┼┼─────────╢ ┘ + ║ Widget4 │ ││ ║ + ║ (2,0) │ ││ ║ + ╟─────────┼─────────┼┼─────────╢ + ║ │ ││ Widget5 ║ + ║ │ ││ (3,3) ║ + ╚═════════╧═════════╧╧═════════╝ + + +Examples +======== + +1 - Simple TTkLayout_ +--------------------- + +Following is the code to execute `Layout Example`_ in pyTermTk_ + +.. code:: python + + import TermTk as ttk + + # TTkLayout is used by default + root = ttk.TTk() + + # Attach 4 buttons to the root widget + ttk.TTkButton(parent=root, pos=(0,0), size=(15,5), border=True, text="Button1") + ttk.TTkButton(parent=root, pos=(0,5), size=(10,4), border=True, text="Button2") + ttk.TTkButton(parent=root, pos=(10,6), size=(10,3), border=True, text="Button3") + ttk.TTkButton(parent=root, pos=(13,1), size=(15,3), border=True, text="Button4") + + root.mainloop() + +The above code produces the following output: + +:: + + ┌─────────────┐ + │ ┌─────────────┐ + │ Button1 │ Button4 │ + │ ╘═════════════╛ + ╘═════════════╛ + ┌────────┐ + │Button2 │┌────────┐ + │ ││Button3 │ + ╘════════╛╘════════╛ + + +2 - Simple TTkVBoxLayout_ +------------------------- + +Following is the code to execute `VBox Example`_ in pyTermTk_ + +.. code:: python + + import TermTk as ttk + + # Set the VBoxLayout as defaut in the terminal widget + root = ttk.TTk(layout=ttk.TTkVBoxLayout()) + + # Attach 4 buttons to the root widget + ttk.TTkButton(parent=root, border=True, text="Button1") + ttk.TTkButton(parent=root, border=True, text="Button2") + ttk.TTkButton(parent=root, border=True, text="Button3") + ttk.TTkButton(parent=root, border=True, text="Button4") + + root.mainloop() + +The above code produces the following output: + +:: + + ┌───────────────────────────────────────────────────────────┐ + │ │ + │ Button1 │ + │ │ + ╘═══════════════════════════════════════════════════════════╛ + ┌───────────────────────────────────────────────────────────┐ + │ │ + │ Button2 │ + │ │ + ╘═══════════════════════════════════════════════════════════╛ + ┌───────────────────────────────────────────────────────────┐ + │ │ + │ Button3 │ + │ │ + ╘═══════════════════════════════════════════════════════════╛ + ┌───────────────────────────────────────────────────────────┐ + │ │ + │ Button4 │ + │ │ + ╘═══════════════════════════════════════════════════════════╛ + + +3 - Simple TTkHBoxLayout_ +------------------------- + +Following is the code to execute `HBox Example`_ in pyTermTk_ + +.. code:: python + + import TermTk as ttk + + # Set the HBoxLayout as defaut in the terminal widget + root = ttk.TTk() + root.setLayout(ttk.TTkHBoxLayout()) + + # Attach 4 buttons to the root widget + ttk.TTkButton(parent=root, border=True, text="Button1") + ttk.TTkButton(parent=root, border=True, text="Button2") + ttk.TTkButton(parent=root, border=True, text="Button3") + ttk.TTkButton(parent=root, border=True, text="Button4") + + root.mainloop() + +The above code produces the following output + +:: + + ┌─────────────┐┌─────────────┐┌─────────────┐┌──────────────┐ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ Button1 ││ Button2 ││ Button3 ││ Button4 │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + │ ││ ││ ││ │ + ╘═════════════╛╘═════════════╛╘═════════════╛╘══════════════╛ + + +4 - Simple TTkGridLayout_ +------------------------- + +Following is the code to execute `HBox Example`_ in pyTermTk_ + + +.. code:: python + + import TermTk as ttk + + # Set the GridLayout as defaut in the terminal widget + gridLayout = ttk.TTkGridLayout(columnMinHeight=0,columnMinWidth=2) + root = ttk.TTk(layout=gridLayout) + + # Attach 2 buttons to the root widget using the default method + # this will append them to the first row + ttk.TTkButton(parent=root, border=True, text="Button1") + ttk.TTkButton(parent=root, border=True, text="Button2") + # Attach 2 buttons to a specific position in the grid + gridLayout.addWidget(ttk.TTkButton(parent=root, border=True, text="Button3"), 1,2) + gridLayout.addWidget(ttk.TTkButton(parent=root, border=True, text="Button4"), 3,4) + + root.mainloop() + +The above code produces the following output + +:: + + ┌───────────┐┌───────────┐ + │ ││ │ + │ Button1 ││ Button2 │ + │ ││ │ + ╘═══════════╛╘═══════════╛ + ┌───────────┐ + │ │ + │ Button3 │ + │ │ + ╘═══════════╛ + ┌───────────┐ + │ │ + │ Button4 │ + │ │ + ╘═══════════╛ + + +5 - Nested Layouts +------------------ + +Following is the code to execute `Nested Layouts Example`_ in pyTermTk_ + +.. code:: python + + import TermTk as ttk + + # Set the GridLayout as defaut in the terminal widget + root = ttk.TTk() + + gridLayout = ttk.TTkGridLayout() + root.setLayout(gridLayout) + + # Attach 2 buttons to the root widget using the default method + # this will append them to the first row + # NOTE: it is not recommended to use this legacy method in a gridLayout + ttk.TTkButton(parent=root, border=True, text="Button1") + ttk.TTkButton(parent=root, border=True, text="Button2") + # Attach 2 buttons to a specific position in the grid + gridLayout.addWidget(ttk.TTkButton(border=True, text="Button3"), 1,2) + gridLayout.addWidget(ttk.TTkButton(border=True, text="Button4"), 2,4) + + # Create a VBoxLayout and add it to the gridLayout + vboxLayout = ttk.TTkVBoxLayout() + gridLayout.addItem(vboxLayout,1,3) + # Attach 2 buttons to the vBoxLayout + vboxLayout.addWidget(ttk.TTkButton(border=True, text="Button5")) + vboxLayout.addWidget(ttk.TTkButton(border=True, text="Button6")) + + root.mainloop() + +The above code produces the following output + +:: + + ┌─────────┐┌─────────┐ + │ ││ │ + │ Button1 ││ Button2 │ + │ ││ │ + ╘═════════╛╘═════════╛ + ┌─────────┐┌─────────┐ + │ ││ Button5 │ + │ Button3 │╘═════════╛ + │ │┌─────────┐ + │ ││ Button6 │ + ╘═════════╛╘═════════╛ + ┌─────────┐ + │ │ + │ Button4 │ + │ │ + ╘═════════╛ + + +6 - Rowspan/Colspan in Grid Layout +---------------------------------- + +Following is the code to execute `row/colspan Example`_ in pyTermTk_ + + +.. code:: python + + import TermTk as ttk + + root = ttk.TTk() + + gridLayout = ttk.TTkGridLayout() + root.setLayout(gridLayout) + + # | x = 0 | x = 1 | x = 2 | + # | | | | + # ┌────────────────┐┌─────────┐ ────── + # │y=0 x=0 h=1 w=2 ││y=0 x=2 │ y = 0 + # │ Button1 ││h=2 w=1 │ + # ╘════════════════╛│ │ ────── + # ┌─────────┐ │ Button2 │ y = 1 + # │y=1 x=0 │ ╘═════════╛ + # │h=2 w=1 │┌────────────────┐ ────── + # │ ││y=2 x=1 h=1 w=2 | y = 2 + # │ Button3 ││ Button4 │ + # ╘═════════╛╘════════════════╛ ────── + + gridLayout.addWidget(ttk.TTkButton(border=True, text="Button1"), 0,0, 1,2) + gridLayout.addWidget(ttk.TTkButton(border=True, text="Button2"), 0,2, 2,1) + gridLayout.addWidget(ttk.TTkButton(border=True, text="Button3"), 1,0, 2,1) + # It is possible to expand the names + gridLayout.addWidget(ttk.TTkButton(border=True, text="Button4"), row=2, col=1, rowspan=1, colspan=2) + + root.mainloop() + +The above code produces the following output + +:: + + ┌───────────────────────┐┌───────────┐ + │ ││ │ + │ Button1 ││ │ + │ ││ │ + ╘═══════════════════════╛│ Button2 │ + ┌───────────┐ │ │ + │ │ │ │ + │ │ │ │ + │ │ ╘═══════════╛ + │ Button3 │┌───────────────────────┐ + │ ││ │ + │ ││ Button4 │ + │ ││ │ + ╘═══════════╛╘═══════════════════════╛ + diff --git a/_sources/tutorial/003-signalslots.rst.txt b/_sources/tutorial/003-signalslots.rst.txt new file mode 100644 index 00000000..6c9380e1 --- /dev/null +++ b/_sources/tutorial/003-signalslots.rst.txt @@ -0,0 +1,157 @@ +.. _pyTermTk: https://github.com/ceccopierangiolieugenio/pyTermTk +.. _TermTk: https://github.com/ceccopierangiolieugenio/pyTermTk + +.. _`TermTk Signal&Slots`: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkCore.signal.html +.. _`Qt5 Signal&Slots`: https://www.riverbankcomputing.com/static/Docs/PyQt5/signals_slots.html + +.. _TTkWidgets: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.html + +.. _windows: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkWidgets/window.html +.. _TTkLabel: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.label.html#TermTk.TTkWidgets.label.TTkLabel +.. _TTkLayouts: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/index.html +.. _TTkLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/layout.html#TermTk.TTkLayouts.layout.TTkLayout +.. _TTkHBoxLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/boxlayout.html#TermTk.TTkLayouts.boxlayout.TTkHBoxLayout +.. _TTkVBoxLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/boxlayout.html#TermTk.TTkLayouts.boxlayout.TTkVBoxLayout +.. _TTkGridLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/TTkLayouts/gridlayout.html#TermTk.TTkLayouts.gridlayout.TTkGridLayout + +.. _Layout Example: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example1.simple.layout.py +.. _VBox Example: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example2.simple.vbox.py +.. _HBox Example: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example3.simple.hbox.py +.. _Grid Example: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example4.simple.grid.py +.. _Nested Layouts Example: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example5.nested.layouts.py +.. _`row/colspan Example`: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example6.grid.span.py + +============================================================================= +pyTermTk_ - Signal & Slots +============================================================================= + +Signals and slots are used for communication between objects. + +Intro +===== + +| The `TermTk Signal&Slots`_ is more than heavily inspired by `Qt5 Signal&Slots`_ +| https://doc.qt.io/qt-5/signalsandslots.html + +| In GUI programming, when we change one widget, we often want another widget to be notified. +| More generally, we want objects of any kind to be able to communicate with one another. +| For example, if a user clicks a Close button, we probably want the window's close() function to be called. + +Signal and Slots +================ + +| A signal is emitted when a particular event occurs. +| A slot is a function that is called in response to a particular signal. +| TermTk_'s TTkWidgets_ have many predefined signals/slots, but it is possible to subclass any TTkWidgets_ and add our own signals/slots to them. + +.. image:: /_static/Signal.Slots.001.svg + +Examples +======== + +Example 1 - basic signal slots +------------------------------ + +From `example1.basic.signalslots.py `_ + +.. code:: python + + import TermTk as ttk + + ttk.TTkLog.use_default_stdout_logging() + + # define 2 signals with different signatures + signal = ttk.pyTTkSignal() + otherSignal = ttk.pyTTkSignal(int) + + + # Define a slot with no input as signature + @ttk.pyTTkSlot() + def slot(): + ttk.TTkLog.debug("Received a simple signal") + + # Define 2 slots with "int" as input signature + @ttk.pyTTkSlot(int) + def otherSlot(val): + ttk.TTkLog.debug(f"[otherSlot] Received a valued signal, val:{val}") + + @ttk.pyTTkSlot(int) + def anotherSlot(val): + ttk.TTkLog.debug(f"[anootherSlot] Received a valued signal, val:{val}") + + + # connect the signals to the proper slot + signal.connect(slot) + otherSignal.connect(otherSlot) + otherSignal.connect(anotherSlot) + + # Test the signals + ttk.TTkLog.debug("Emit a simple signal") + signal.emit() + ttk.TTkLog.debug("Emit a valued signal") + otherSignal.emit(123) + +The above code produces the following output + +:: + + $ tutorial/signalslots/example1.basic.signalslots.py + DEBUG:(MainThread) tutorial/signalslots/example1.basic.signalslots.py:54 Emit a simple signal + DEBUG:(MainThread) tutorial/signalslots/example1.basic.signalslots.py:37 Received a simple signal + DEBUG:(MainThread) tutorial/signalslots/example1.basic.signalslots.py:56 Emit a valued signal + DEBUG:(MainThread) tutorial/signalslots/example1.basic.signalslots.py:42 [otherSlot] Received a valued signal, val:123 + DEBUG:(MainThread) tutorial/signalslots/example1.basic.signalslots.py:45 [anootherSlot] Received a valued signal, val:123 + + +Example 2 - Use widgets signals and slots +----------------------------------------- + +From `example2.widgets.signalslots.py `_ + +.. code:: python + + import TermTk as ttk + + root = ttk.TTk() + + # Create a window with a logviewer + logWin = ttk.TTkWindow(parent=root,pos = (10,2), size=(80,20), title="LogViewer Window", border=True, layout=ttk.TTkVBoxLayout()) + ttk.TTkLogViewer(parent=logWin) + + # Create 2 buttons + btnShow = ttk.TTkButton(parent=root, text="Show", pos=(0,0), size=(10,3), border=True) + btnHide = ttk.TTkButton(parent=root, text="Hide", pos=(0,3), size=(10,3), border=True) + + # Connect the btnShow's "clicked" signal with the window's "show" slot + btnShow.clicked.connect(logWin.show) + # Connect the btnHide's "clicked" signal with the window's "hide" slot + btnHide.clicked.connect(logWin.hide) + + root.mainloop() + +A screenshot is totally useless for this example but for the sack of completemess, the above code produces the following output + +:: + + ┌────────┐ + │ Show │ + ╘════════╛╔══════════════════════════════════════════════════════════════════════════════╗ + ┌────────┐║ LogViewer Window ║ + │ Hide │╟──────────────────────────────────────────────────────────────────────────────╢ + ╘════════╛║ ║ + ║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:70 Starting M║ + ║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:80 Signal Eve║ + ║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:65 fps: 33 ║ + ║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:65 fps: 34 ║ + ║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:65 fps: 34 ║ + ║ ║ + ║ ║ + ║ ║ + ║ ║ + ║ ║ + ║ ║ + ║ ║ + ║ ║ + ║ ║ + ║◀▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓┄┄┄┄┄┄┄┄┄┄┄▶║ + ╚══════════════════════════════════════════════════════════════════════════════╝ diff --git a/_sources/tutorial/004-logging.rst.txt b/_sources/tutorial/004-logging.rst.txt new file mode 100644 index 00000000..fd71b212 --- /dev/null +++ b/_sources/tutorial/004-logging.rst.txt @@ -0,0 +1,139 @@ +.. _pyTermTk: https://github.com/ceccopierangiolieugenio/pyTermTk +.. _TermTk: https://github.com/ceccopierangiolieugenio/pyTermTk + +.. _TTkLog: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkCore.log.html +.. _TTlLogViewer: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkTestWidgets.logviewer.html + +=================== +pyTermTk_ - Logging +=================== + +Intro +===== + +The TTkLog_ class provide a set of api to allow and configure the logging. + +Examples +======== + +Example 1 - Log to file +----------------------- + +From `example1.logtofile.py `_ + +.. code:: python + + import TermTk as ttk + + # session.log is used by default + ttk.TTkLog.use_default_file_logging() + + # Push some Debug messages + ttk.TTkLog.info( "Test Info Message") + ttk.TTkLog.debug( "Test Debug Message") + ttk.TTkLog.error( "Test Error Message") + ttk.TTkLog.warn( "Test Warning Message") + ttk.TTkLog.critical("Test Critical Message") + + +Example 2 - Log to stdout +------------------------- + +From `example2.logtostdout.py `_ + +.. code:: python + + import TermTk as ttk + + ttk.TTkLog.use_default_stdout_logging() + + # Push some Debug messages + ttk.TTkLog.info( "Test Info Message") + ttk.TTkLog.debug( "Test Debug Message") + ttk.TTkLog.error( "Test Error Message") + ttk.TTkLog.warn( "Test Warning Message") + ttk.TTkLog.critical("Test Critical Message") + ttk.TTkLog.fatal( "Test Fatal Message") + +Example 3 - custom logging +-------------------------- + +From `example3.customlogging.py `_ + +.. code:: python + + import TermTk as ttk + + # define the callback used to process the log message + def message_handler(mode, context, message): + msgType = "NONE" + if mode == ttk.TTkLog.InfoMsg: msgType = "[INFO]" + elif mode == ttk.TTkLog.WarningMsg: msgType = "[WARNING]" + elif mode == ttk.TTkLog.CriticalMsg: msgType = "[CRITICAL]" + elif mode == ttk.TTkLog.FatalMsg: msgType = "[FATAL]" + elif mode == ttk.TTkLog.ErrorMsg: msgType = "[ERROR]" + print(f"{msgType} {context.file} {message}") + + # Register the callback to the message handler + ttk.TTkLog.installMessageHandler(message_handler) + + # Push some Debug messages + ttk.TTkLog.info( "Test Info Message") + ttk.TTkLog.debug( "Test Debug Message") + ttk.TTkLog.error( "Test Error Message") + ttk.TTkLog.warn( "Test Warning Message") + ttk.TTkLog.critical("Test Critical Message") + ttk.TTkLog.fatal( "Test Fatal Message") + +Example 4 - Use TTlLogViewer_ widget +-------------------------------------------------- + +From `example4.ttklogviewer.py `_ + +.. code:: python + + import TermTk as ttk + + root = ttk.TTk() + + # Create a window and attach it to the root (parent=root) + logWin = ttk.TTkWindow(parent=root,pos = (1,1), size=(80,20), title="LogViewer Window", border=True, layout=ttk.TTkVBoxLayout()) + + # Attach the logViewer widget to the window + ttk.TTkLogViewer(parent=logWin) + + # Push some Debug messages + ttk.TTkLog.info( "Test Info Message") + ttk.TTkLog.debug( "Test Debug Message") + ttk.TTkLog.error( "Test Error Message") + ttk.TTkLog.warn( "Test Warning Message") + ttk.TTkLog.critical("Test Critical Message") + ttk.TTkLog.fatal( "Test Fatal Message") + + # Start the Main loop + root.mainloop() + +The above code produces the following output + +:: + + ╔══════════════════════════════════════════════════════════════════════════════╗ + ║ LogViewer Window ║ + ╟──────────────────────────────────────────────────────────────────────────────╢ + ║ ║ + ║INFO : tutorial/logging/example4.ttklogviewer.py:36 Test Info Message ║ + ║DEBUG: tutorial/logging/example4.ttklogviewer.py:37 Test Debug Message ║ + ║ERROR: tutorial/logging/example4.ttklogviewer.py:38 Test Error Message ║ + ║WARNING : tutorial/logging/example4.ttklogviewer.py:39 Test Warning Message ║ + ║CRITICAL: tutorial/logging/example4.ttklogviewer.py:40 Test Critical Message ║ + ║FATAL: tutorial/logging/example4.ttklogviewer.py:41 Test Fatal Message ║ + ║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:70 Starting M║ + ║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:80 Signal Eve║ + ║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:65 fps: 33 ║ + ║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:65 fps: 34 ║ + ║DEBUG: _/.venv/lib/python3.8/site-packages/TermTk/TTkCore/ttk.py:65 fps: 34 ║ + ║ ║ + ║ ║ + ║ ║ + ║◀▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓┄┄┄┄┄┄┄┄┄┄┄▶║ + ╚══════════════════════════════════════════════════════════════════════════════╝ diff --git a/_static/theme_overrides.css b/_static/theme_overrides.css index bb3d4b94..0a5d9ac7 100644 --- a/_static/theme_overrides.css +++ b/_static/theme_overrides.css @@ -1,4 +1,4 @@ -/* In a bid to be "mobile-friendly" by default about 1/3 of the horizontal space is wasted; +/* In a bid to be "mobile-friendly" by default about 1/3 of the horizontal space is wasted; this CSS removes the wasted space. */ .wy-nav-content { max-width: none; @@ -18,5 +18,18 @@ .wy-table-responsive { overflow: visible !important; } + + .wy-menu p { + color: #55a5d9; + height: 32px; + line-height: 32px; + padding: 0 1.618em; + margin: 12px 0 0; + display: block; + font-weight: 700; + text-transform: uppercase; + font-size: 85%; + white-space: nowrap; + } } diff --git a/autogen.TermTk/TermTk.TTkAbstract.abstractitemmodel.html b/autogen.TermTk/TermTk.TTkAbstract.abstractitemmodel.html index 180455f1..28d2176e 100644 --- a/autogen.TermTk/TermTk.TTkAbstract.abstractitemmodel.html +++ b/autogen.TermTk/TermTk.TTkAbstract.abstractitemmodel.html @@ -86,25 +86,29 @@ -

Contents:

-
-../_static/Signal.Slots.001.svg +../_images/Signal.Slots.001.svg

Methods

diff --git a/autogen.TermTk/TermTk.TTkCore.timer.html b/autogen.TermTk/TermTk.TTkCore.timer.html index b35a5ad0..fb4ec31f 100644 --- a/autogen.TermTk/TermTk.TTkCore.timer.html +++ b/autogen.TermTk/TermTk.TTkCore.timer.html @@ -86,36 +86,40 @@ -

Contents:

-
diff --git a/autogen.TermTk/TermTk.TTkGui.html b/autogen.TermTk/TermTk.TTkGui.html index 13a8654b..18d18290 100644 --- a/autogen.TermTk/TermTk.TTkGui.html +++ b/autogen.TermTk/TermTk.TTkGui.html @@ -86,23 +86,27 @@ -

Contents:

-