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 :param pos: the position (col or row) of the header
:type pos: int :type pos: int
:param orientation: the orienttin of the header to be retrieved :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` :return: :py:class:`TTkString`
''' '''
@ -258,7 +258,7 @@ class TTkAbstractTableModel():
:param col: the column position of the data :param col: the column position of the data
:type col: int :type col: int
:return: :py:class:`~TermTk.TTkCore.constant.TTkConstant.ItemFlag` :return: :py:class:`TTkConstant.ItemFlag`
''' '''
return ( return (
TTkK.ItemFlag.ItemIsEnabled | 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. :param column: The column index to be sorted, if -1 is provided the original unsorted order is used.
:type column: int :type column: int
:param order: the sorting order :param order: the sorting order
:type order: :py:class:`~TermTk.TTkCore.constant.TTkConstant.SortOrder` :type order: :py:class:`TTkConstant.SortOrder`
''' '''
pass 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>`_ :Demo: `test.input.py <https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tests/test.input.py>`_
:param type: The key input type recorded :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 :param key: the key
:type key: str :type key: str
:param code: The terminal code used to represent this input :param code: The terminal code used to represent this input
:type code: str :type code: str
:param mod: The modifier used by the :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyType.SpecialKey` type :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 .. py:attribute:: type
:type: KeyType :type: KeyType
The key input :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyType` recorded The key input :py:class:`TTkConstant.KeyType` recorded
.. py:attribute:: key .. py:attribute:: key
:type: str :type: str
@ -56,7 +56,7 @@ class TTkKeyEvent:
.. py:attribute:: mod .. py:attribute:: mod
:type: KeyModifier :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') __slots__ = ('type', 'key', 'code', 'mod')
@ -403,8 +403,7 @@ def mod2str(k):
if ret: return ",".join(ret) if ret: return ",".join(ret)
return "NONE!!!" return "NONE!!!"
def key2str(k): _def_hey_map= {
return {
TTkK.Key_Escape : "Key_Escape" , TTkK.Key_Escape : "Key_Escape" ,
TTkK.Key_Tab : "Key_Tab" , TTkK.Key_Tab : "Key_Tab" ,
TTkK.Key_Backtab : "Key_Backtab" , TTkK.Key_Backtab : "Key_Backtab" ,
@ -875,4 +874,7 @@ def key2str(k):
TTkK.Key_Zoom : "Key_Zoom" , TTkK.Key_Zoom : "Key_Zoom" ,
TTkK.Key_Exit : "Key_Exit" , TTkK.Key_Exit : "Key_Exit" ,
TTkK.Key_Cancel : "Key_Cancel" 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 .. py:attribute:: key
:type: MouseKey :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 .. py:attribute:: mod
:type: KeyModifier :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 .. py:attribute:: evt
:type: MouseEvent :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 .. py:attribute:: tap
:type: int :type: int

6
TermTk/TTkCore/color.py

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

12
TermTk/TTkCore/constant.py

@ -201,7 +201,7 @@ class TTkConstant:
class MouseKey(int): class MouseKey(int):
'''Input Mouse Key '''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:: .. autosummary::
NoButton NoButton
@ -284,7 +284,7 @@ class TTkConstant:
class MouseEvent(int): class MouseEvent(int):
'''Input Mouse Event '''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:: .. autosummary::
NoEvent NoEvent
@ -506,7 +506,7 @@ class TTkConstant:
class KeyType(int): class KeyType(int):
'''Input Key Types '''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:: .. autosummary::
Character Character
@ -524,7 +524,7 @@ class TTkConstant:
class KeyModifier(int): class KeyModifier(int):
'''Input :py:class:`~TermTk.TTkCore.constant.TTkConstant.KeyType.SpecialKey` modifiers '''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:: .. autosummary::
NoModifier NoModifier
@ -1074,4 +1074,6 @@ class TTkConstant:
# Alias to 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 "" :param text: text of the string, defaults to ""
:type text: str, optional :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 :type color: :py:class:`TTkColor`, optional
Example: Example:
@ -321,10 +321,10 @@ class TTkString():
:param width: the new width :param width: the new width
:type width: int, optional :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 :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` :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() lentxt = self.termWidth()
if not width or width == lentxt: return self 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 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` :type color: :py:class:`TTkColor`
:param match: the match to colorize :param match: the match to colorize
:type match: str, optional :type match: str, optional
@ -489,7 +489,7 @@ class TTkString():
If only the color is specified, the entire string is colorized 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` :type color: :py:class:`TTkColor`
:param match: the match to colorize :param match: the match to colorize
:type match: str, optional :type match: str, optional

2
TermTk/TTkCore/ttk.py

@ -311,7 +311,7 @@ class TTk(TTkContainer):
.. warning:: .. warning::
Method Deprecated, 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. i.e.

2
TermTk/TTkLayouts/__init__.py

@ -2,7 +2,7 @@
Layouts Layouts
======= =======
.. image:: /../_images/Layout.HLD.001.svg .. image:: ../_images/Layout.HLD.001.svg
''' '''
from .layout import * from .layout import *
from .gridlayout 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 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 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` :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) 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 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 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` :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) self.removeWidgets(widgets)
items = [w.widgetItem() for w in 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 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 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` :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) 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 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 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` :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) nitems = len(items)
self.removeItems(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 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 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 :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) :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 LAYER0 = 0x00000000

4
TermTk/TTkWidgets/TTkModelView/tablewidget.py

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

8
TermTk/TTkWidgets/TTkPickers/filepicker.py

@ -109,10 +109,10 @@ class TTkFileDialogPicker(TTkWindow):
:type filter: str, optional :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` :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` :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 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` :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` :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>`_ | | `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): def checkState(self):
''' Retrieve the state of the checkbox ''' 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 return self._checkStatus
@ -176,7 +176,7 @@ class TTkCheckbox(TTkWidget):
''' Sets the checkbox's check state. ''' Sets the checkbox's check state.
:param state: state of the checkbox :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 self._checkStatus == state: return
if state==TTkK.PartiallyChecked and not self._tristate: 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 :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` :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` :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 :param editable: This property holds whether the combo box can be edited by the user, defaults to False
:type editable: bool, optional :type editable: bool, optional
@ -122,7 +122,7 @@ class TTkComboBox(TTkContainer):
def textAlign(self): def textAlign(self):
'''his property holds the displayed text alignment '''his property holds the displayed text alignment
:return: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Alignment` :return: :py:class:`TTkConstant.Alignment`
''' '''
return self._textAlign return self._textAlign
@ -130,7 +130,7 @@ class TTkComboBox(TTkContainer):
'''This property holds the displayed text alignment '''This property holds the displayed text alignment
:param align: :param align:
:type align: :py:class:`~TermTk.TTkCore.constant.TTkConstant.Alignment` :type align: :py:class:`TTkConstant.Alignment`
''' '''
if self._textAlign != align: if self._textAlign != align:
self._textAlign = align self._textAlign = align

4
TermTk/TTkWidgets/container.py

@ -87,7 +87,7 @@ class TTkContainer(TTkWidget):
.. warning:: .. warning::
Method Deprecated, 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. i.e.
@ -103,7 +103,7 @@ class TTkContainer(TTkWidget):
.. warning:: .. warning::
Method Deprecated, 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. i.e.

4
TermTk/TTkWidgets/radiobutton.py

@ -132,7 +132,7 @@ class TTkRadioButton(TTkWidget):
def checkState(self): def checkState(self):
''' Retrieve the state of the radiobutton ''' 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: if self._checked:
return TTkK.Checked return TTkK.Checked
@ -143,7 +143,7 @@ class TTkRadioButton(TTkWidget):
''' Sets the radiobutton's check state. ''' Sets the radiobutton's check state.
:param state: state of the checkbox :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 not self._checked and state == TTkK.Unchecked: return
if 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 = "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 # 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()). # 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 = 'sphinxawesome_theme'
html_theme = 'sphinx_book_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 = { html_theme_options = {
"home_page_in_toc": True, "home_page_in_toc": True,
"use_fullscreen_button": True, "use_fullscreen_button": True,
@ -129,7 +134,7 @@ html_theme_options = {
"repository_url": "https://github.com/ceccopierangiolieugenio/pyTermTk", "repository_url": "https://github.com/ceccopierangiolieugenio/pyTermTk",
} }
add_module_names = True add_module_names = False
autosummary_generate = True autosummary_generate = True
autosummary_generate_overwrite = True autosummary_generate_overwrite = True
autosummary_imported_members = False autosummary_imported_members = False

89
docs/source/index.rst

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

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

@ -8,82 +8,113 @@ Widgets
Base 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 .. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.Base.gif
* Label :class:`~TermTk.TTkWidgets.label.TTkLabel`
* Button :class:`~TermTk.TTkWidgets.button.TTkButton` * List :py:class:`TTkList`
* 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`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.List.gif .. 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 .. 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 .. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.Tab.gif
* Tab :class:`~TermTk.TTkWidgets.tabwidget.TTkTabWidget`
Specialised Widgets Specialised Widgets
------------------- -------------------
* TextEdit :py:class:`TTkTextEdit`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TextEdit.gif .. 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 .. 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 .. 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:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TTkImage.gif
* Image :class:`~TermTk.TTkWidgets.image.TTkImage`
.. _widgets-pickers:
Model View 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.Demo.gif
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TreeWidget.ttkDesigner.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.01.gif
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TableWidget.02.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 .. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.FileTree.gif
* File Tree :class:`~TermTk.TTkWidgets.TTkModelView.filetree.TTkFileTree`
.. _widgets-pickers:
Pickers Pickers
------- -------
* Text Picker :py:class:`TTkTextPicker`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.TextPicker.gif .. 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 .. 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 .. 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 .. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.MessageBox.gif
* Message Box :class:`~TermTk.TTkWidgets.TTkPickers.messagebox.TTkMessageBox`
.. _widgets-layout: .. _widgets-layout:
Layout Layout
------ ------
* Frame :class:`~TermTk.TTkWidgets.frame.TTkFrame` * Frame :py:class:`TTkFrame`
* Resizable Frame :class:`~TermTk.TTkWidgets.resizableframe.TTkResizableFrame` * Resizable Frame :py:class:`TTkResizableFrame`
* Window :class:`~TermTk.TTkWidgets.window.TTkWindow` * Window :py:class:`TTkWindow`
* Splitter :class:`~TermTk.TTkWidgets.splitter.TTkSplitter` * Splitter :py:class:`TTkSplitter`
* Scroll Area :class:`~TermTk.TTkWidgets.scrollarea.TTkScrollArea` * Scroll Area :py:class:`TTkScrollArea`
* App Template :py:class:`TTkAppTemplate`
.. image:: https://ceccopierangiolieugenio.github.io/binaryRepo/pyTermTk/images/pyTermTk.Widgets.AppTemplate.gif .. 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(): for x in modules.items():
print(x) 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 _process_link_bk = sphinxPythonDomain.PyXRefRole.process_link
def _hacked_process_link(self, env, refnode, def _hacked_process_link(self, env, refnode,
has_explicit_title, title: str, target, _process_link_bk=_process_link_bk) -> tuple[str, str]: has_explicit_title, title: str, target, _process_link_bk=_process_link_bk) -> tuple[str, str]:
print(f"-----------> HACKED !!! {title=} {target=}") print(f"-----------> HACKED !!! {title=} {target=}")
oldTitle = title # title = _resolve(title)
if title in modules: target = _resolve(target)
title = f"~{modules[title]}.{title}"
print(f"-----------> {oldTitle=} -> {title=}")
oldTarget = target
if target in modules:
target = f"~{modules[target]}.{target}"
print(f"-----------> {oldTarget=} -> {target=}")
return _process_link_bk(self, env, refnode, return _process_link_bk(self, env, refnode,
has_explicit_title, title, target) has_explicit_title, title, target)

169
docs/source/sphinx_modules/sphinx_ext_autosummary_reworked.py

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

10
docs/source/static/theme_overrides.css

@ -14,7 +14,15 @@
.bd-page-width { .bd-page-width {
max-width: none; 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 /* 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 Pippo CUSTOM_CLASS_TEMPLATE.001
@ -8,6 +8,9 @@ Pippo CUSTOM_CLASS_TEMPLATE.001
:show-inheritance: :show-inheritance:
{% if TTkStyle %} {% if TTkStyle %}
.. _{{ module }}.{{ objname }}.classStyle:
Style Style
----- -----
@ -28,19 +31,33 @@ Pippo CUSTOM_CLASS_TEMPLATE.001
{%- endfor %} {%- endfor %}
{% endif %} {% endif %}
{% if TTkSlots %} {% if TTkSlots or TTkSlotsInherited %}
:ref:`Slots <Signal and Slots>` :ref:`Slots <Signal and Slots>`
------------------------------- -------------------------------
{% endif %}
{% if TTkSlots %}
.. autosummary:: .. autosummary::
{% for item in TTkSlots %} {% for item in TTkSlots %}
{{ item }} {{ item }}
{%- endfor %} {%- endfor %}
{% endif %} {% 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 Members
------- -------
@ -50,7 +67,6 @@ Pippo CUSTOM_CLASS_TEMPLATE.001
{% endif %} {% endif %}
{% if TTkMethods %} {% if TTkMethods %}
Methods Methods
------- -------
@ -59,3 +75,38 @@ Pippo CUSTOM_CLASS_TEMPLATE.001
{%- endfor %} {%- endfor %}
{% endif %} {% 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}} {{ fullname | escape | underline}}
Pippo CUSTOM_MODULE_TEMPLATE.001
.. automodule:: {{ fullname }} .. automodule:: {{ fullname }}
{% if TTkSubClasses %} {% if TTkSubClasses %}
@ -21,7 +19,7 @@ Pippo CUSTOM_MODULE_TEMPLATE.001
.. rubric:: {{ _('Modules') }} .. rubric:: {{ _('Modules') }}
.. autosummary:: .. autosummary::
:toctree: Modules: :toctree:
:template: custom-module-template.01.rst :template: custom-module-template.01.rst
:recursive: :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 .. _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 .. _`row/colspan Example`: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/tutorial/layout/example6.grid.span.py
============================================================================= =============================================================================
pyTermTk_ - Signal & Slots pyTermTk_ - Signal & Slots
============================================================================= =============================================================================
Signals and slots are used for communication between objects. Signals and slots are used for communication between objects.
.. _Signal and Slots:
Intro Intro
===== =====

Loading…
Cancel
Save