Browse Source

Doc eworking progress

pull/278/head
Eugenio Parodi 1 year ago
parent
commit
3d483a489c
  1. 6
      TermTk/TTkAbstract/abstracttablemodel.py
  2. 16
      TermTk/TTkCore/TTkTerm/inputkey.py
  3. 6
      TermTk/TTkCore/TTkTerm/inputmouse.py
  4. 6
      TermTk/TTkCore/color.py
  5. 12
      TermTk/TTkCore/constant.py
  6. 10
      TermTk/TTkCore/string.py
  7. 2
      TermTk/TTkCore/ttk.py
  8. 2
      TermTk/TTkLayouts/__init__.py
  9. 8
      TermTk/TTkLayouts/gridlayout.py
  10. 4
      TermTk/TTkLayouts/layout.py
  11. 4
      TermTk/TTkWidgets/TTkModelView/tablewidget.py
  12. 8
      TermTk/TTkWidgets/TTkPickers/filepicker.py
  13. 4
      TermTk/TTkWidgets/checkbox.py
  14. 8
      TermTk/TTkWidgets/combobox.py
  15. 4
      TermTk/TTkWidgets/container.py
  16. 4
      TermTk/TTkWidgets/radiobutton.py
  17. BIN
      docs/images/favicon.png
  18. 7
      docs/source/conf.py
  19. 89
      docs/source/index.rst
  20. 89
      docs/source/info/features/widgets.rst
  21. 23
      docs/source/sphinx_modules/sphinx_PyRefRole_hacked.py
  22. 169
      docs/source/sphinx_modules/sphinx_ext_autosummary_reworked.py
  23. 10
      docs/source/static/theme_overrides.css
  24. 59
      docs/source/templates/custom-class-template.01.rst
  25. 4
      docs/source/templates/custom-module-template.01.rst
  26. 3
      tutorial/003-signalslots.rst

6
TermTk/TTkAbstract/abstracttablemodel.py

@ -235,7 +235,7 @@ class TTkAbstractTableModel():
:param pos: the position (col or row) of the header
:type pos: int
:param orientation: the orienttin of the header to be retrieved
:type orientation: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Direction`
:type orientation: :py:class:`TTkConstant.Direction`
:return: :py:class:`TTkString`
'''
@ -258,7 +258,7 @@ class TTkAbstractTableModel():
:param col: the column position of the data
:type col: int
:return: :py:class:`~TermTk.TTkCore.constant.TTkConstant.ItemFlag`
:return: :py:class:`TTkConstant.ItemFlag`
'''
return (
TTkK.ItemFlag.ItemIsEnabled |
@ -271,6 +271,6 @@ class TTkAbstractTableModel():
:param column: The column index to be sorted, if -1 is provided the original unsorted order is used.
:type column: int
:param order: the sorting order
:type order: :py:class:`~TermTk.TTkCore.constant.TTkConstant.SortOrder`
:type order: :py:class:`TTkConstant.SortOrder`
'''
pass

16
TermTk/TTkCore/TTkTerm/inputkey.py

@ -30,18 +30,18 @@ class TTkKeyEvent:
:Demo: `test.input.py <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tests/test.input.py>`_
:param type: The key input type recorded
:type type: :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyType`
:type type: :py:class:`TTkConstant.KeyType`
:param key: the key
:type key: str
:param code: The terminal code used to represent this input
:type code: str
:param mod: The modifier used by the :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyType.SpecialKey` type
:type mod: :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyModifier`
:type mod: :py:class:`TTkConstant.KeyModifier`
.. py:attribute:: type
:type: KeyType
The key input :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyType` recorded
The key input :py:class:`TTkConstant.KeyType` recorded
.. py:attribute:: key
:type: str
@ -56,7 +56,7 @@ class TTkKeyEvent:
.. py:attribute:: mod
:type: KeyModifier
The :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyModifier` used by the :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyType.SpecialKey` type
The :py:class:`TTkConstant.KeyModifier` used by the :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyType.SpecialKey` type
'''
__slots__ = ('type', 'key', 'code', 'mod')
@ -403,8 +403,7 @@ def mod2str(k):
if ret: return ",".join(ret)
return "NONE!!!"
def key2str(k):
return {
_def_hey_map= {
TTkK.Key_Escape : "Key_Escape" ,
TTkK.Key_Tab : "Key_Tab" ,
TTkK.Key_Backtab : "Key_Backtab" ,
@ -875,4 +874,7 @@ def key2str(k):
TTkK.Key_Zoom : "Key_Zoom" ,
TTkK.Key_Exit : "Key_Exit" ,
TTkK.Key_Cancel : "Key_Cancel"
}.get(k, "NONE!!!")
}
def key2str(k):
return _def_hey_map.get(k, "NONE!!!")

6
TermTk/TTkCore/TTkTerm/inputmouse.py

@ -42,17 +42,17 @@ class TTkMouseEvent:
.. py:attribute:: key
:type: MouseKey
The :py:class:`~TermTk.TTkCore.constant.TTkConstant.MouseKey` reported in this event (i.e. :py:class:`~TermTk.TTkCore.constant.TTkConstant.MouseKey.LeftButton`)
The :py:class:`TTkConstant.MouseKey` reported in this event (i.e. :py:class:`~TermTk.TTkCore.constant.TTkConstant.MouseKey.LeftButton`)
.. py:attribute:: mod
:type: KeyModifier
The :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyModifier` used, default :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyModifier.NoModifier`
The :py:class:`TTkConstant.KeyModifier` used, default :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyModifier.NoModifier`
.. py:attribute:: evt
:type: MouseEvent
The :py:class:`~TermTk.TTkCore.constant.TTkConstant.MouseEvent` reported in this event (i.e. :py:class:`~TermTk.TTkCore.constant.TTkConstant.MouseKey.Press`)
The :py:class:`TTkConstant.MouseEvent` reported in this event (i.e. :py:class:`~TermTk.TTkCore.constant.TTkConstant.MouseKey.Press`)
.. py:attribute:: tap
:type: int

6
TermTk/TTkCore/color.py

@ -267,6 +267,8 @@ class _TTkColorModifier():
def copy(self): return self
class TTkColorGradient(_TTkColorModifier):
'''TTkColorGradient'''
__slots__ = ('_fgincrement', '_bgincrement', '_val', '_step', '_buffer', '_orientation')
_increment: int; _val: int
def __init__(self, *args, **kwargs):
@ -317,6 +319,8 @@ class TTkColorGradient(_TTkColorModifier):
return self
class TTkLinearGradient(_TTkColorModifier):
'''TTkLinearGradient'''
__slots__ = (
'_direction', '_direction_squaredlength',
'_base_pos', '_target_color')
@ -553,6 +557,8 @@ class TTkColor(_TTkColor):
return TTkColor(fg=TTkColor.hexToRGB(fg), bg=TTkColor.hexToRGB(bg), colorMod=modifier, link=link)
class TTkAlternateColor(_TTkColorModifier):
'''TTkAlternateColor'''
__slots__ = ('_alternateColor')
def __init__(self, alternateColor:TTkColor=TTkColor.RST, **kwargs):
super().__init__(**kwargs)

12
TermTk/TTkCore/constant.py

@ -201,7 +201,7 @@ class TTkConstant:
class MouseKey(int):
'''Input Mouse Key
Events reported by :py:class:`TTkMouseEvent` -> :py:class:`~TermTk.TTkCore.TTkTerm.inputmouse.TTkMouseEvent.key`
Events reported by :py:class:`TTkMouseEvent` -> :py:class:`TTkMouseEvent.key`
.. autosummary::
NoButton
@ -284,7 +284,7 @@ class TTkConstant:
class MouseEvent(int):
'''Input Mouse Event
Events reported by :py:class:`TTkMouseEvent` -> :py:class:`~TermTk.TTkCore.TTkTerm.inputmouse.TTkMouseEvent.evt`
Events reported by :py:class:`TTkMouseEvent` -> :py:class:`TTkMouseEvent.evt`
.. autosummary::
NoEvent
@ -506,7 +506,7 @@ class TTkConstant:
class KeyType(int):
'''Input Key Types
Key type reported by :py:class:`TTkKeyEvent` -> :py:class:`~TermTk.TTkCore.TTkTerm.inputkey.TTkKeyEvent.key`
Key type reported by :py:class:`TTkKeyEvent` -> :py:class:`TTkKeyEvent.key`
.. autosummary::
Character
@ -524,7 +524,7 @@ class TTkConstant:
class KeyModifier(int):
'''Input :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyType.SpecialKey` modifiers
Modifier reported by :py:class:`TTkKeyEvent` -> :py:class:`~TermTk.TTkCore.TTkTerm.inputkey.TTkKeyEvent.mod`
Modifier reported by :py:class:`TTkKeyEvent` -> :py:class:`TTkKeyEvent.mod`
.. autosummary::
NoModifier
@ -1074,4 +1074,6 @@ class TTkConstant:
# Alias to TTkConstant
class TTkK(TTkConstant): pass
class TTkK(TTkConstant):
'''Class container of all the constants used in :mod:`~TermTk`'''
pass

10
TermTk/TTkCore/string.py

@ -37,7 +37,7 @@ class TTkString():
:param text: text of the string, defaults to ""
:type text: str, optional
:param color: the color of the string, defaults to :py:class:`~TermTk.TTkCore.color.TTkColor.RST`
:param color: the color of the string, defaults to :py:class:`TTkColor.RST`
:type color: :py:class:`TTkColor`, optional
Example:
@ -321,10 +321,10 @@ class TTkString():
:param width: the new width
:type width: int, optional
:param color: the color of the padding, defaults to :py:class:`~TermTk.TTkCore.color.TTkColor.RST`
:param color: the color of the padding, defaults to :py:class:`TTkColor.RST`
:type color: :py:class:`TTkColor`, optional
:param alignment: the alignment of the text to the full width :py:class:`~TermTk.TTkCore.constant.TTkConstant.Alignment.NONE`
:type alignment: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Alignment`, optional
:type alignment: :py:class:`TTkConstant.Alignment`, optional
'''
lentxt = self.termWidth()
if not width or width == lentxt: return self
@ -450,7 +450,7 @@ class TTkString():
If only the color is specified, the entire string is colorized
:param color: the color to be used, defaults to :py:class:`~TermTk.TTkCore.color.TTkColor.RST`
:param color: the color to be used, defaults to :py:class:`TTkColor.RST`
:type color: :py:class:`TTkColor`
:param match: the match to colorize
:type match: str, optional
@ -489,7 +489,7 @@ class TTkString():
If only the color is specified, the entire string is colorized
:param color: the color to be used, defaults to :py:class:`~TermTk.TTkCore.color.TTkColor.RST`
:param color: the color to be used, defaults to :py:class:`TTkColor.RST`
:type color: :py:class:`TTkColor`
:param match: the match to colorize
:type match: str, optional

2
TermTk/TTkCore/ttk.py

@ -311,7 +311,7 @@ class TTk(TTkContainer):
.. warning::
Method Deprecated,
use :py:class:`TTkHelper` -> :py:class:`~TermTk.TTkCore.helper.TTkHelper.quit` instead
use :py:class:`TTkHelper` -> :py:class:`TTkHelper.quit` instead
i.e.

2
TermTk/TTkLayouts/__init__.py

@ -2,7 +2,7 @@
Layouts
=======
.. image:: /../_images/Layout.HLD.001.svg
.. image:: ../_images/Layout.HLD.001.svg
'''
from .layout import *
from .gridlayout import *

8
TermTk/TTkLayouts/gridlayout.py

@ -182,7 +182,7 @@ class TTkGridLayout(TTkLayout):
:param int rowspan: the rows used by the widget, optional, defaults to 1
:param int colspan: the cols used by the widget, optional, defaults to 1
:param direction: The direction the new item will be added if row/col are not specified, defaults to defaults to :py:class:`~TermTk.TTkCore.constant.TTkConstant.Direction.HORIZONTAL`
:type direction: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Direction`
:type direction: :py:class:`TTkConstant.Direction`
'''
TTkGridLayout.addWidgets(self,[widget], row, col, rowspan, colspan, direction)
@ -196,7 +196,7 @@ class TTkGridLayout(TTkLayout):
:param int rowspan: the rows used by the widget, optional, defaults to 1
:param int colspan: the cols used by the widget, optional, defaults to 1
:param direction: The direction the new items will be added if row/col are not specified, defaults to defaults to :py:class:`~TermTk.TTkCore.constant.TTkConstant.Direction.HORIZONTAL`
:type direction: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Direction`
:type direction: :py:class:`TTkConstant.Direction`
'''
self.removeWidgets(widgets)
items = [w.widgetItem() for w in widgets]
@ -216,7 +216,7 @@ class TTkGridLayout(TTkLayout):
:param int rowspan: the rows used by the item, optional, defaults to 1
:param int colspan: the cols used by the item, optional, defaults to 1
:param direction: The direction the new item will be added if row/col are not specified, defaults to defaults to :py:class:`~TermTk.TTkCore.constant.TTkConstant.Direction.HORIZONTAL`
:type direction: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Direction`
:type direction: :py:class:`TTkConstant.Direction`
'''
self.addItems([item],row,col,rowspan,colspan,direction)
@ -230,7 +230,7 @@ class TTkGridLayout(TTkLayout):
:param int rowspan: the rows used by the item, optional, defaults to 1
:param int colspan: the cols used by the item, optional, defaults to 1
:param direction: The direction the new items will be added if row/col are not specified, defaults to defaults to :py:class:`~TermTk.TTkCore.constant.TTkConstant.Direction.HORIZONTAL`
:type direction: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Direction`
:type direction: :py:class:`TTkConstant.Direction`
'''
nitems = len(items)
self.removeItems(items)

4
TermTk/TTkLayouts/layout.py

@ -36,9 +36,9 @@ class TTkLayoutItem:
:param int rowspan: (used only in the :py:class:`TTkGridLayout`), the rows used by this, optional, defaults to 1
:param int colspan: (used only in the :py:class:`TTkGridLayout`), the cols used by this, optional, defaults to 1
:param layoutItemType: The Type of this class, optional, defaults to TTkK.NONE
:type layoutItemType: :py:class:`~TermTk.TTkCore.constant.TTkConstant.LayoutItemTypes`
:type layoutItemType: :py:class:`TTkConstant.LayoutItemTypes`
:param alignment: The alignment of this item in the layout (not yet used)
:type alignment: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Alignment`
:type alignment: :py:class:`TTkConstant.Alignment`
'''
LAYER0 = 0x00000000

4
TermTk/TTkWidgets/TTkModelView/tablewidget.py

@ -511,7 +511,7 @@ class TTkTableWidget(TTkAbstractScrollView):
:type column: bool
:param order: the sort order
:type order: :py:class:`~TermTk.TTkCore.constant.TTkK.SortOrder`
:type order: :py:class:`TTkK.SortOrder`
'''
self._sortColumn = column
self._sortOrder = order
@ -600,7 +600,7 @@ class TTkTableWidget(TTkAbstractScrollView):
:type pos: tuple[int,int]
:param size: the width,height of the rect used for the selection
:type size: tuple[int,int]
:param flags: the selection model used (i.e. :py:class:`~TermTk.TTkCore.constant.TTkK.TTkItemSelectionModel.Select`)
:param flags: the selection model used (i.e. :py:class:`TTkItemSelectionModel.Select`)
:type flags: :py:class:`TTkItemSelectionModel`
'''
x,y = pos

8
TermTk/TTkWidgets/TTkPickers/filepicker.py

@ -109,10 +109,10 @@ class TTkFileDialogPicker(TTkWindow):
:type filter: str, optional
:param fileMode: The file mode defines the number and type of items that the user is expected to select in the dialog, defaults to :py:class:`~TermTk.TTkCore.constant.TTkConstant.FileMode.Anyfile`
:type fileMode: :py:class:`~TermTk.TTkCore.constant.TTkConstant.FileMode`, optional
:type fileMode: :py:class:`TTkConstant.FileMode`, optional
:param acceptMode: TThe action mode defines whether the dialog is for opening or saving files, defaults to :py:class:`~TermTk.TTkCore.constant.TTkConstant.AcceptMode.AcceptOpen`
:type acceptMode: :py:class:`~TermTk.TTkCore.constant.TTkConstant.AcceptMode`, optional
:type acceptMode: :py:class:`TTkConstant.AcceptMode`, optional
'''
pathPicked:pyTTkSignal
@ -427,10 +427,10 @@ class TTkFileButtonPicker(TTkButton):
:param fileMode: The file mode defines the number and type of items that the user is expected to select in the dialog, defaults to :py:class:`~TermTk.TTkCore.constant.TTkConstant.FileMode.Anyfile`
:type fileMode: :py:class:`~TermTk.TTkCore.constant.TTkConstant.FileMode`, optional
:type fileMode: :py:class:`TTkConstant.FileMode`, optional
:param acceptMode: TThe action mode defines whether the dialog is for opening or saving files, defaults to :py:class:`~TermTk.TTkCore.constant.TTkConstant.AcceptMode.AcceptOpen`
:type acceptMode: :py:class:`~TermTk.TTkCore.constant.TTkConstant.AcceptMode`, optional
:type acceptMode: :py:class:`TTkConstant.AcceptMode`, optional
+-----------------------------------------------------------------------------------------------+
| `Signals <https://ceccopierangiolieugenio.github.io/pyTermTk/tutorial/003-signalslots.html>`_ |

4
TermTk/TTkWidgets/checkbox.py

@ -167,7 +167,7 @@ class TTkCheckbox(TTkWidget):
def checkState(self):
''' Retrieve the state of the checkbox
:return: :py:class:`~TermTk.TTkCore.constant.TTkConstant.CheckState` : the checkbox status
:return: :py:class:`TTkConstant.CheckState` : the checkbox status
'''
return self._checkStatus
@ -176,7 +176,7 @@ class TTkCheckbox(TTkWidget):
''' Sets the checkbox's check state.
:param state: state of the checkbox
:type state: :py:class:`~TermTk.TTkCore.constant.TTkConstant.CheckState`
:type state: :py:class:`TTkConstant.CheckState`
'''
if self._checkStatus == state: return
if state==TTkK.PartiallyChecked and not self._tristate: return

8
TermTk/TTkWidgets/combobox.py

@ -53,10 +53,10 @@ class TTkComboBox(TTkContainer):
:type list: list(str), optional
:param insertPolicy: the policy used to determine where user-inserted items should appear in the combobox, defaults to :py:class:`~TermTk.TTkCore.constant.TTkConstant.InsertPolicy.InsertAtBottom`
:type insertPolicy: :py:class:`~TermTk.TTkCore.constant.TTkConstant.InsertPolicy`, optional
:type insertPolicy: :py:class:`TTkConstant.InsertPolicy`, optional
:param textAlign: This enum type is used to define the text alignment, defaults to :py:class:`~TermTk.TTkCore.constant.TTkConstant.Alignment.CENTER_ALIGN`
:tye textAlign: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Alignment`, optional
:tye textAlign: :py:class:`TTkConstant.Alignment`, optional
:param editable: This property holds whether the combo box can be edited by the user, defaults to False
:type editable: bool, optional
@ -122,7 +122,7 @@ class TTkComboBox(TTkContainer):
def textAlign(self):
'''his property holds the displayed text alignment
:return: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Alignment`
:return: :py:class:`TTkConstant.Alignment`
'''
return self._textAlign
@ -130,7 +130,7 @@ class TTkComboBox(TTkContainer):
'''This property holds the displayed text alignment
:param align:
:type align: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Alignment`
:type align: :py:class:`TTkConstant.Alignment`
'''
if self._textAlign != align:
self._textAlign = align

4
TermTk/TTkWidgets/container.py

@ -87,7 +87,7 @@ class TTkContainer(TTkWidget):
.. warning::
Method Deprecated,
use :py:class:`TTkWidget` -> :py:class:`~TermTk.TTkWidgets.widget.TTkWidget.layout` -> :py:class:`~TermTk.TTkLayouts.layout.TTkLayout.addWidget`
use :py:class:`TTkWidget` -> :py:class:`TTkWidget.layout` -> :py:class:`TTkLayout.addWidget`
i.e.
@ -103,7 +103,7 @@ class TTkContainer(TTkWidget):
.. warning::
Method Deprecated,
use :py:class:`TTkWidget` -> :py:class:`~TermTk.TTkWidgets.widget.TTkWidget.layout` -> :py:class:`~TermTk.TTkLayouts.layout.TTkLayout.removeWidget`
use :py:class:`TTkWidget` -> :py:class:`TTkWidget.layout` -> :py:class:`TTkLayout.removeWidget`
i.e.

4
TermTk/TTkWidgets/radiobutton.py

@ -132,7 +132,7 @@ class TTkRadioButton(TTkWidget):
def checkState(self):
''' Retrieve the state of the radiobutton
:return: :py:class:`~TermTk.TTkCore.constant.TTkConstant.CheckState` : the checkbox status
:return: :py:class:`TTkConstant.CheckState` : the checkbox status
'''
if self._checked:
return TTkK.Checked
@ -143,7 +143,7 @@ class TTkRadioButton(TTkWidget):
''' Sets the radiobutton's check state.
:param state: state of the checkbox
:type state: :py:class:`~TermTk.TTkCore.constant.TTkConstant.CheckState`
:type state: :py:class:`TTkConstant.CheckState`
'''
if not self._checked and state == TTkK.Unchecked: return
if self._checked and state != TTkK.Unchecked: return

BIN
docs/images/favicon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

7
docs/source/conf.py

@ -71,6 +71,8 @@ html_css_files = [
]
html_favicon = "https://ceccopierangiolieugenio.github.io/pyTermTk/sandbox/www/favicon.ico"
# html_favicon = "_images/favicon.ico"
# html_favicon = "../images/favicon.ico"
# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-toc_object_entries_show_parents
# Use 'hide' to only show the name of the element without any parents (i.e. method()).
@ -122,6 +124,9 @@ toc_object_entries_show_parents='hide'
# html_theme = 'sphinxawesome_theme'
html_theme = 'sphinx_book_theme'
html_permalinks_icon = '<span>🌶</span>'
# html_permalinks_icon = '<span><image src="/_images/favicon.png"></span>'
# html_permalinks_icon = '<span><image src="https://ceccopierangiolieugenio.github.io/pyTermTk/sandbox/www/favicon.ico"></span>'
html_theme_options = {
"home_page_in_toc": True,
"use_fullscreen_button": True,
@ -129,7 +134,7 @@ html_theme_options = {
"repository_url": "https://github.com/ceccopierangiolieugenio/pyTermTk",
}
add_module_names = True
add_module_names = False
autosummary_generate = True
autosummary_generate_overwrite = True
autosummary_imported_members = False

89
docs/source/index.rst

@ -80,49 +80,72 @@ Intro
info/debug
info/resources/index
API Reference
=============
.. currentmodule:: TermTk
.. autosummary::
:caption: API Reference
:toctree: _autosummary
:template: custom-module-template.01.rst
:recursive:
TTkAbstract
TTkCore
TTkGui
TTkLayouts
TTkAbstract
TTkTemplates
TTkTestWidgets
TTkUiTools
TTkWidgets
TTkWidgets.TTkModelView
| TermTk.TTkAbstract
| TermTk.TTkCore
| TermTk.TTkCore.TTkTerm
| TermTk.TTkGui
| TermTk.TTkLayouts
| TermTk.TTkTemplates
| TermTk.TTkTestWidgets
| TermTk.TTkTheme
| TermTk.TTkTypes
| TermTk.TTkUiTools
| TermTk.TTkWidgets
| TermTk.TTkWidgets.TTkModelView
| TermTk.TTkWidgets.TTkPickers
| TermTk.TTkWidgets.TTkTerminal
| TTkAbstract
| TermTk.TTkCore
| TermTk.TTkCore.TTkTerm
| TermTk.TTkGui
| TermTk.TTkLayouts
| TermTk.TTkTemplates
| TermTk.TTkTestWidgets
| TermTk.TTkTheme
| TermTk.TTkTypes
| TermTk.TTkUiTools
| TermTk.TTkWidgets
| TermTk.TTkWidgets.TTkModelView
| TermTk.TTkWidgets.TTkPickers
| TermTk.TTkWidgets.TTkTerminal
TTkWidgets.TTkPickers
TTkWidgets.TTkTerminal
.. # .. autosummary::
.. # :caption: Classes:
.. # :toctree: _autosummary
.. # :template: custom-class-template.01.rst
.. #
.. # TTkCore.TTkK
.. # TTkCore.TTkConstant
.. # TTkWidgets.TTkWidget
.. # TTkWidgets.TTkContainer
.. # TTkWidgets.TTkScrollBar
.. # | TTkCore.TTk
.. # | TTkCore.TTkHelper
.. # | TTkCore.TTkColor
.. #
.. # | TermTk.TTkAbstract
.. # | TermTk.TTkCore
.. # | TermTk.TTkCore.TTkTerm
.. # | TermTk.TTkGui
.. # | TermTk.TTkLayouts
.. # | TermTk.TTkTemplates
.. # | TermTk.TTkTestWidgets
.. # | TermTk.TTkTheme
.. # | TermTk.TTkTypes
.. # | TermTk.TTkUiTools
.. # | TermTk.TTkWidgets
.. # | TermTk.TTkWidgets.TTkModelView
.. # | TermTk.TTkWidgets.TTkPickers
.. # | TermTk.TTkWidgets.TTkTerminal
.. #
.. # | TTkAbstract
.. # | TermTk.TTkCore
.. # | TermTk.TTkCore.TTkTerm
.. # | TermTk.TTkGui
.. # | TermTk.TTkLayouts
.. # | TermTk.TTkTemplates
.. # | TermTk.TTkTestWidgets
.. # | TermTk.TTkTheme
.. # | TermTk.TTkTypes
.. # | TermTk.TTkUiTools
.. # | TermTk.TTkWidgets
.. # | TermTk.TTkWidgets.TTkModelView
.. # | TermTk.TTkWidgets.TTkPickers
.. # | TermTk.TTkWidgets.TTkTerminal
Indices and tables
==================

89
docs/source/info/features/widgets.rst

@ -8,82 +8,113 @@ Widgets
Base Widgets
------------
* Label :py:class:`TTkLabel`
* Button :py:class:`TTkButton`
* ComboBox :py:class:`TTkCombobox`
* Line Edit :py:class:`TTkLineedit`
* Spinbox :py:class:`TTkSpinbox`
* Checkbox :py:class:`TTkCheckbox`
* Radio Button :py:class:`TTkRadiobutton`
* Scrollbar :py:class:`TTkScrollBar`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.Base.gif
* Label :class:`~TermTk.TTkWidgets.label.TTkLabel`
* Button :class:`~TermTk.TTkWidgets.button.TTkButton`
* ComboBox :class:`~TermTk.TTkWidgets.combobox.TTkCombobox`
* Line Edit :class:`~TermTk.TTkWidgets.lineedit.TTkLineedit`
* Spinbox :class:`~TermTk.TTkWidgets.spinbox.TTkSpinbox`
* Checkbox :class:`~TermTk.TTkWidgets.checkbox.TTkCheckbox`
* Radio Button :class:`~TermTk.TTkWidgets.radiobutton.TTkRadiobutton`
* Scrollbar :class:`~TermTk.TTkWidgets.scrollbar.TTkScrollBar`
* List :py:class:`TTkList`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.List.gif
* List :class:`~TermTk.TTkWidgets.list_.TTkList`
* Menu :py:class:`TTkMenu`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.Menu.gif
* Menu :class:`~TermTk.TTkWidgets.menu.TTkMenu`
* Tab :py:class:`TTkTabWidget`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.Tab.gif
* Tab :class:`~TermTk.TTkWidgets.tabwidget.TTkTabWidget`
Specialised Widgets
-------------------
* TextEdit :py:class:`TTkTextEdit`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TextEdit.gif
* TextEdit :class:`~TermTk.TTkWidgets.texedit.TTkTextEdit`
* KodeTab :py:class:`TTkKodeTab`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.KodeTab.gif
* KodeTab :class:`~TermTk.TTkWidgets.kodetab.TTkKodeTab`
* Terminal :py:class:`TTkTerminal`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.Terminal.gif
* Terminal :class:`~TermTk.TTkWidgets.TTkTerminal.terminal.TTkTerminal`
* Image :py:class:`TTkImage`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TTkImage.gif
* Image :class:`~TermTk.TTkWidgets.image.TTkImage`
.. _widgets-pickers:
Model View
----------
* Tree Widget :py:class:`TTkTree`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TreeWidget.Demo.gif
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TreeWidget.ttkDesigner.gif
* Tree Widget :class:`~TermTk.TTkWidgets.TTkModelView.tree.TTkTree`
* Table Widget :py:class:`TTkTable`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TableWidget.01.gif
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TableWidget.02.gif
* Table Widget :class:`~TermTk.TTkWidgets.TTkModelView.table.TTkTable`
* File Tree :py:class:`TTkFileTree`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.FileTree.gif
* File Tree :class:`~TermTk.TTkWidgets.TTkModelView.filetree.TTkFileTree`
.. _widgets-pickers:
Pickers
-------
* Text Picker :py:class:`TTkTextPicker`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TextPicker.gif
* Text Picker :class:`~TermTk.TTkWidgets.TTkPickers.textpicker.TTkTextPicker`
* File Picker :py:class:`TTkFileButtonPicker`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.FilePicker.gif
* File Picker :class:`~TermTk.TTkWidgets.TTkPickers.filepicker.TTkFileButtonPicker`
* Color Picker :py:class:`TTkColorButtonPicker`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.ColorPicker.gif
* Color Picker :class:`~TermTk.TTkWidgets.TTkPickers.colorpicker.TTkColorButtonPicker`
* Message Box :py:class:`TTkMessageBox`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.MessageBox.gif
* Message Box :class:`~TermTk.TTkWidgets.TTkPickers.messagebox.TTkMessageBox`
.. _widgets-layout:
Layout
------
* Frame :class:`~TermTk.TTkWidgets.frame.TTkFrame`
* Resizable Frame :class:`~TermTk.TTkWidgets.resizableframe.TTkResizableFrame`
* Window :class:`~TermTk.TTkWidgets.window.TTkWindow`
* Splitter :class:`~TermTk.TTkWidgets.splitter.TTkSplitter`
* Scroll Area :class:`~TermTk.TTkWidgets.scrollarea.TTkScrollArea`
* Frame :py:class:`TTkFrame`
* Resizable Frame :py:class:`TTkResizableFrame`
* Window :py:class:`TTkWindow`
* Splitter :py:class:`TTkSplitter`
* Scroll Area :py:class:`TTkScrollArea`
* App Template :py:class:`TTkAppTemplate`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.AppTemplate.gif
* App Template :class:`~TermTk.TTkWidgets.apptemplate.TTkAppTemplate`

23
docs/source/sphinx_modules/sphinx_PyRefRole_hacked.py

@ -60,18 +60,25 @@ def setup(app: Sphinx) -> ExtensionMetadata:
for x in modules.items():
print(x)
def _resolve(txt) -> str:
oldTxt = txt
if txt in modules:
txt = f"~{modules[txt]}.{txt}"
print(f"-----------> {oldTxt=} -> {txt=}")
else:
txts = txt.split('.')
if txts[0] in modules:
txts[0] = f"~{modules[txts[0]]}.{txts[0]}"
txt = '.'.join(txts)
print(f"-----------> {oldTxt=} -> {txt=}")
return txt
_process_link_bk = sphinxPythonDomain.PyXRefRole.process_link
def _hacked_process_link(self, env, refnode,
has_explicit_title, title: str, target, _process_link_bk=_process_link_bk) -> tuple[str, str]:
print(f"-----------> HACKED !!! {title=} {target=}")
oldTitle = title
if title in modules:
title = f"~{modules[title]}.{title}"
print(f"-----------> {oldTitle=} -> {title=}")
oldTarget = target
if target in modules:
target = f"~{modules[target]}.{target}"
print(f"-----------> {oldTarget=} -> {target=}")
# title = _resolve(title)
target = _resolve(target)
return _process_link_bk(self, env, refnode,
has_explicit_title, title, target)

169
docs/source/sphinx_modules/sphinx_ext_autosummary_reworked.py

@ -39,7 +39,7 @@ import inspect
# From
# https://stackoverflow.com/questions/3232024/introspection-to-get-decorator-names-on-a-method
def get_decorators(cls):
def _get_decorators(cls):
target = cls
decorators = {}
@ -59,6 +59,11 @@ def get_decorators(cls):
node_iter.visit(ast.parse(inspect.getsource(target)))
return decorators
def _get_attributes(obj,filter):
return sorted([item for item in (set(dir(obj)) - set(filter)) if not item.startswith('_') and not inspect.isclass(getattr(obj,item))])
def _get_classes(obj,filter):
return sorted([item for item in (set(dir(obj)) - set(filter)) if not item.startswith('_') and inspect.isclass(getattr(obj,item))])
_styleMatch = re.compile('^ *classStyle')
_colorMatch = re.compile('^#[0-9a-fA-F]{6}')
@ -83,11 +88,11 @@ def _get_classStyleCode(obj) -> list[str]:
# print(line)
# print(f"{_styleMatch.match(line)=}")
if curlyBraket == 0 and _styleMatch.match(line):
print(line)
# print(line)
ret.append(line)
curlyBraket += _processLine(line)
elif curlyBraket > 0:
print(line)
# print(line)
ret.append(line)
curlyBraket += _processLine(line)
if curlyBraket == 0:
@ -102,13 +107,45 @@ def setup(app: Sphinx) -> ExtensionMetadata:
modSub = {}
modSubSorted = {}
modStyles = {}
ttkAllSignals={}
ttkAllMethods={}
ttkAllSlots={}
ttkAllMembers={} # List all the member of a class
ttkInherited={} # List of the inherited classes for each class
def _getMethodsAndSlots(_obj):
retSlots = []
retMethods = []
def _hasmethod(obj, name):
return hasattr(obj, name) and type(getattr(obj, name)) in (types.MethodType, types.FunctionType)
for _name in (_dec:=_get_decorators(_obj)):
if _name.startswith('_'): continue
if _hasmethod(_obj,_name):
retMethods.append(_name)
for _decorator in _dec[_name]:
if "pyTTkSlot"in _decorator:
retSlots.append(_name)
break
return retMethods,retSlots
def _getInherited(_obj):
ret = []
for cc in _obj.__mro__:
if cc==_obj: continue
# if hasattr(cc,'_ttkProperties'):
if issubclass(cc, ttk.TTkWidget) or issubclass(cc, ttk.TTkLayout):
ccName = cc.__name__
ret.append(ccName)
# print(ccName)
# print(f"_getInherited {ret}")
return ret
def _getSignals(_obj):
ret = []
for _name in (_th:=get_type_hints(_obj)):
print(f"{_th=}")
# print(f"{_th=}")
if _name.startswith('_'): continue
if 'pyTTkSignal' in str(_th[_name]):
ret.append(_name)
@ -119,12 +156,19 @@ def setup(app: Sphinx) -> ExtensionMetadata:
def _parseModules(_mod):
if _file:=getattr(_mod,'__file__',None):
if '__init__.py' in _file and '/TermTk/' in _file:
print(_file)
# print(_file)
for _name, _obj in inspect.getmembers(_mod):
if _mod.__name__ == 'TermTk.TTkCore.drivers': continue
if inspect.isclass(_obj):
_meth,_slots = _getMethodsAndSlots(_obj)
if _name not in ttkAllMethods:
ttkAllMethods[_name] = _meth
if _name not in ttkAllSlots:
ttkAllSlots[_name] = _slots
if _name not in ttkAllSignals:
ttkAllSignals[_name] = _getSignals(_obj)
if _name not in ttkInherited:
ttkInherited[_name] = _getInherited(_obj)
if _name not in modStyles:
modStyles[_name] = _get_classStyleCode(_obj)
if _name not in modules:
@ -164,81 +208,78 @@ def setup(app: Sphinx) -> ExtensionMetadata:
for x in b:
print (f" - {x}")
for (x,y) in ttkInherited.items():
print(f"Inherited {x} -> {y}")
# print(modStyles)
# raise Exception
def generate_autosummary_content(
def generate_autosummary_content_hack(
name, obj, parent, template, template_name, imported_members,
app, recursive, context, modname, qualname,
generate_autosummary_content_old = seautogenerate.generate_autosummary_content
) -> str:
print(f"-----------------> OVERRIDEEEEE!!! {type(context)}")
print(f"{name=}")
print(f"{obj=}")
print(f"{parent=}")
print(f"{template=}")
print(f"{template_name=}")
print(f"{imported_members=}")
print(f"{app=}")
print(f"{recursive=}")
print(f"{context=}")
# print(f"{obj=}")
# print(f"{parent=}")
# print(f"{template=}")
# print(f"{template_name=}")
# print(f"{imported_members=}")
# print(f"{app=}")
# print(f"{recursive=}")
# print(f"{context=}")
print(f"{modname=}")
print(f"{qualname=}")
ttkSignals = []
ttkSignalsImported = {}
ttkSlots = []
ttkSlotsImported = {}
ttkSlotsInherited = {}
ttkMethods = []
ttkInheritedMethods = []
ttkSubClasses = modSorted.get(name,[])
ttkSubModules = modSubSorted.get(name,[])
# ns['members'] = dir(obj)
# ns['inherited_members'] = set(dir(obj)) - set(obj.__dict__.keys())
# ns['methods'], ns['all_methods'] = _get_members(
# doc, app, obj, {'method'}, include_public={'__init__'}
# )
# ns['attributes'], ns['all_attributes'] = _get_members(
# doc, app, obj, {'attribute', 'property'}
# )
print(f"{obj=}")
# for member in inspect.getmembers(obj):
# _name = member[0]
# if _name.startswith('_'): continue
# _hint = get_type_hints(obj)[_name]
# print(f"{obj=} - {get_type_hints(obj)=}")
# for _name in (_th:=get_type_hints(obj)):
# print(f"{_th=}")
# if _name.startswith('_'): continue
# if 'pyTTkSignal' in str(_th[_name]):
# ttkSignals.append(_name)
# else:
# print(ttk.TTkString(f"element not typed: {_name} - { _th[_name]}",ttk.TTkColor.BG_CYAN))
# print(ttkSignals)
def _hasmethod(obj, name):
return hasattr(obj, name) and type(getattr(obj, name)) in (types.MethodType, types.FunctionType)
for _name in (_dec:=get_decorators(obj)):
if _name.startswith('_'): continue
if _hasmethod(obj,_name):
ttkMethods.append(_name)
for _decorator in _dec[_name]:
if "pyTTkSlot"in _decorator:
ttkSlots.append(_name)
break
def _get_slots_in_obj(_name):
_slotsInherited = {_sub : sorted(ttkAllSlots.get(_sub,[])) for _sub in ttkInherited.get(_name,[])}
_slots = set(ttkAllSlots.get(_name,[])) - set([_sl for _subSl in _slotsInherited.values() for _sl in _subSl])
return sorted(list(_slots)), _slotsInherited
ttkSlots, ttkSlotsInherited = _get_slots_in_obj(qualname)
def _get_attributes_in_obj(_obj,_name):
_allMethods = ttkAllMethods.get(_name,[])
_slots = ttkAllSlots.get(_name,[])
_signals = ttkAllSignals.get(_name,[])
_classes = _get_classes(_obj,[])
return _get_attributes(_obj,_allMethods+_slots+_signals+_classes)
def _get_simple_attributes(_obj):
return sorted(set(
[item for item in dir(obj)
if (
not (
item.startswith('_') or
inspect.isclass( _attr:=getattr(obj,item)) or
inspect.ismethod( _attr) or
inspect.isfunction(_attr)
) ) ] ) )
ttkAttributes = sorted(set(_get_simple_attributes(obj)) - set(ttkAllSignals.get(qualname,'')))
context |= {
'TTkAttributes':ttkAttributes,
'TTkClasses':_get_classes(obj,ttkMethods+ttkSlots+ttkAllSignals.get(qualname,[])),
'TTkStyle':modStyles.get(qualname,''),
'TTkSignals':ttkAllSignals.get(qualname,''),
'TTkSubClasses': ttkSubClasses,
'TTkSubModules': ttkSubModules,
'TTkMethods':ttkMethods,
'TTkSlots':ttkSlots}
'TTkMethods':ttkAllMethods.get(qualname,''),
'TTkSlots':ttkSlots,
'TTkSlotsInherited':ttkSlotsInherited,
}
print('\n'.join([f" * {x}={context[x]}" for x in context]))
@ -246,6 +287,24 @@ def setup(app: Sphinx) -> ExtensionMetadata:
name, obj, parent, template, template_name, imported_members,
app, recursive, context, modname, qualname)
seautogenerate.generate_autosummary_content = generate_autosummary_content
# def get_import_prefixes_from_env_hack(env, get_import_prefixes_from_env_old=seauto.get_import_prefixes_from_env) -> list[str | None]:
# pyClass = env.ref_context.get('py:class')
# # env.ref_context.set('py:class')
# prefixes = get_import_prefixes_from_env_old(env)
# retPrefixes = []
# for p in prefixes:
# if not p:
# retPrefixes.append(p)
# continue
# psplit = p.split('.')
# cur = ret = psplit[0]
# for pp in psplit[1:]:
# print(f"SPLIT: {pp} - {pyClass=} - {prefixes}")
# if cur != pp:
# ret += f".{pp}"
# retPrefixes.append(ret)
# return retPrefixes
seautogenerate.generate_autosummary_content = generate_autosummary_content_hack
# seauto.get_import_prefixes_from_env = get_import_prefixes_from_env_hack
return seauto.setup(app)

10
docs/source/static/theme_overrides.css

@ -14,7 +14,15 @@
.bd-page-width {
max-width: none;
}
html[data-theme="dark"] .bd-content img:not(.only-dark, .dark-light) {
background-color: transparent;
border-radius: 0;
}
@media (min-width: 992px) {
.bd-sidebar-primary {
flex-basis: 18%;
}
}
/* Temporary workaround for RTD 0.4.3 bug https://github.com/readthedocs/sphinx_rtd_theme/issues/117 which will hopefully be fixed soon
*/

59
docs/source/templates/custom-class-template.01.rst

@ -1,4 +1,4 @@
{{ objname | escape | underline}}
{{ objname | escape | underline }}
Pippo CUSTOM_CLASS_TEMPLATE.001
@ -8,6 +8,9 @@ Pippo CUSTOM_CLASS_TEMPLATE.001
:show-inheritance:
{% if TTkStyle %}
.. _{{ module }}.{{ objname }}.classStyle:
Style
-----
@ -28,19 +31,33 @@ Pippo CUSTOM_CLASS_TEMPLATE.001
{%- endfor %}
{% endif %}
{% if TTkSlots %}
{% if TTkSlots or TTkSlotsInherited %}
:ref:`Slots <Signal and Slots>`
-------------------------------
{% endif %}
{% if TTkSlots %}
.. autosummary::
{% for item in TTkSlots %}
{{ item }}
{%- endfor %}
{% endif %}
{% if TTkSlotsInherited %}
{% for name in TTkSlotsInherited %}
Inherited from: :py:class:`{{ name }}`
{% if TTkSignals %}
.. autosummary::
{% for item in TTkSlotsInherited[name] %}
{{ item }}
{%- endfor %}
{%- endfor %}
{% endif %}
{% if TTkSignals %}
Members
-------
@ -50,7 +67,6 @@ Pippo CUSTOM_CLASS_TEMPLATE.001
{% endif %}
{% if TTkMethods %}
Methods
-------
@ -59,3 +75,38 @@ Pippo CUSTOM_CLASS_TEMPLATE.001
{%- endfor %}
{% endif %}
{% if TTkClasses %}
{{ objname }} Classes
---------------------
{% for item in TTkClasses %}
.. currentmodule:: {{ module }}.{{ objname }}
.. autoclass:: {{ item }}
:show-inheritance:
:members:
{%- endfor %}
.. py:currentmodule:: {{ module }}
{% endif %}
{% if TTkAttributes %}
{{ objname }} Attributes
------------------------
.. currentmodule:: {{ module }}.{{ objname }}
.. autosummary::
{% for item in TTkAttributes %}
{{ item }}
{%- endfor %}
.. currentmodule:: {{ module }}
{% endif %}

4
docs/source/templates/custom-module-template.01.rst

@ -1,7 +1,5 @@
{{ fullname | escape | underline}}
Pippo CUSTOM_MODULE_TEMPLATE.001
.. automodule:: {{ fullname }}
{% if TTkSubClasses %}
@ -21,7 +19,7 @@ Pippo CUSTOM_MODULE_TEMPLATE.001
.. rubric:: {{ _('Modules') }}
.. autosummary::
:toctree: Modules:
:toctree:
:template: custom-module-template.01.rst
:recursive:

3
tutorial/003-signalslots.rst

@ -21,12 +21,15 @@
.. _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.
.. _Signal and Slots:
Intro
=====

Loading…
Cancel
Save