From 3d483a489c8f2651321083192556795dad4d35e1 Mon Sep 17 00:00:00 2001 From: Eugenio Parodi Date: Tue, 29 Oct 2024 23:45:17 +0000 Subject: [PATCH] Doc eworking progress --- TermTk/TTkAbstract/abstracttablemodel.py | 6 +- TermTk/TTkCore/TTkTerm/inputkey.py | 16 +- TermTk/TTkCore/TTkTerm/inputmouse.py | 6 +- TermTk/TTkCore/color.py | 6 + TermTk/TTkCore/constant.py | 12 +- TermTk/TTkCore/string.py | 10 +- TermTk/TTkCore/ttk.py | 2 +- TermTk/TTkLayouts/__init__.py | 2 +- TermTk/TTkLayouts/gridlayout.py | 8 +- TermTk/TTkLayouts/layout.py | 4 +- TermTk/TTkWidgets/TTkModelView/tablewidget.py | 4 +- TermTk/TTkWidgets/TTkPickers/filepicker.py | 8 +- TermTk/TTkWidgets/checkbox.py | 4 +- TermTk/TTkWidgets/combobox.py | 8 +- TermTk/TTkWidgets/container.py | 4 +- TermTk/TTkWidgets/radiobutton.py | 4 +- docs/images/favicon.png | Bin 0 -> 521 bytes docs/source/conf.py | 7 +- docs/source/index.rst | 89 +++++---- docs/source/info/features/widgets.rst | 89 ++++++--- .../sphinx_modules/sphinx_PyRefRole_hacked.py | 23 ++- .../sphinx_ext_autosummary_reworked.py | 169 ++++++++++++------ docs/source/static/theme_overrides.css | 10 +- .../templates/custom-class-template.01.rst | 59 +++++- .../templates/custom-module-template.01.rst | 4 +- tutorial/003-signalslots.rst | 3 + 26 files changed, 376 insertions(+), 181 deletions(-) create mode 100644 docs/images/favicon.png diff --git a/TermTk/TTkAbstract/abstracttablemodel.py b/TermTk/TTkAbstract/abstracttablemodel.py index 98b6a64d..5e2a7e2e 100644 --- a/TermTk/TTkAbstract/abstracttablemodel.py +++ b/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 diff --git a/TermTk/TTkCore/TTkTerm/inputkey.py b/TermTk/TTkCore/TTkTerm/inputkey.py index 35956169..2c53737b 100644 --- a/TermTk/TTkCore/TTkTerm/inputkey.py +++ b/TermTk/TTkCore/TTkTerm/inputkey.py @@ -30,18 +30,18 @@ class TTkKeyEvent: :Demo: `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!!!") \ No newline at end of file + } + +def key2str(k): + return _def_hey_map.get(k, "NONE!!!") \ No newline at end of file diff --git a/TermTk/TTkCore/TTkTerm/inputmouse.py b/TermTk/TTkCore/TTkTerm/inputmouse.py index 16ef8d34..385c3df2 100644 --- a/TermTk/TTkCore/TTkTerm/inputmouse.py +++ b/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 diff --git a/TermTk/TTkCore/color.py b/TermTk/TTkCore/color.py index 4e368061..e66b8ff0 100644 --- a/TermTk/TTkCore/color.py +++ b/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) diff --git a/TermTk/TTkCore/constant.py b/TermTk/TTkCore/constant.py index b30f1ed4..b02502ce 100644 --- a/TermTk/TTkCore/constant.py +++ b/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 diff --git a/TermTk/TTkCore/string.py b/TermTk/TTkCore/string.py index 9af1ea1f..349e4c78 100644 --- a/TermTk/TTkCore/string.py +++ b/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 diff --git a/TermTk/TTkCore/ttk.py b/TermTk/TTkCore/ttk.py index 1f43358e..ae86f46e 100644 --- a/TermTk/TTkCore/ttk.py +++ b/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. diff --git a/TermTk/TTkLayouts/__init__.py b/TermTk/TTkLayouts/__init__.py index 00d8c30e..44a6c56b 100644 --- a/TermTk/TTkLayouts/__init__.py +++ b/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 * diff --git a/TermTk/TTkLayouts/gridlayout.py b/TermTk/TTkLayouts/gridlayout.py index 2fb00277..e331d0db 100644 --- a/TermTk/TTkLayouts/gridlayout.py +++ b/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) diff --git a/TermTk/TTkLayouts/layout.py b/TermTk/TTkLayouts/layout.py index 34c69c22..c27ce329 100644 --- a/TermTk/TTkLayouts/layout.py +++ b/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 diff --git a/TermTk/TTkWidgets/TTkModelView/tablewidget.py b/TermTk/TTkWidgets/TTkModelView/tablewidget.py index 91bea426..87955292 100644 --- a/TermTk/TTkWidgets/TTkModelView/tablewidget.py +++ b/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 diff --git a/TermTk/TTkWidgets/TTkPickers/filepicker.py b/TermTk/TTkWidgets/TTkPickers/filepicker.py index ac688354..95e66c14 100644 --- a/TermTk/TTkWidgets/TTkPickers/filepicker.py +++ b/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 `_ | diff --git a/TermTk/TTkWidgets/checkbox.py b/TermTk/TTkWidgets/checkbox.py index 3ac5a18d..bfe34167 100644 --- a/TermTk/TTkWidgets/checkbox.py +++ b/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 diff --git a/TermTk/TTkWidgets/combobox.py b/TermTk/TTkWidgets/combobox.py index 5c24e9e7..adb901e4 100644 --- a/TermTk/TTkWidgets/combobox.py +++ b/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 diff --git a/TermTk/TTkWidgets/container.py b/TermTk/TTkWidgets/container.py index 49c2be10..ae7f8f6b 100644 --- a/TermTk/TTkWidgets/container.py +++ b/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. diff --git a/TermTk/TTkWidgets/radiobutton.py b/TermTk/TTkWidgets/radiobutton.py index d8b9fe0b..06f1538d 100644 --- a/TermTk/TTkWidgets/radiobutton.py +++ b/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 diff --git a/docs/images/favicon.png b/docs/images/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..76d17f57ad903c3ea2f1b564cafb95bf9af84ee3 GIT binary patch literal 521 zcmV+k0`~ohP)kdg0005dNkl2WptjAn6@db&Pvy?U$ zv>P|<&rCZfZF0jmq0opf8)91(A<*iIVPPJJT((+JiF~>9KAA3%heFdnI;SaK+~|aU zQ~!x`%y{jX1<~SK2RxN7Db8`yWBbf6p7&07{VXfaam*cUs&eu*Zu(xaIL8rP){;a< zS~$}^Td32Rw+W1TqTd|L{#~jJet4!qwKsb5hq%YXiiUV!yH=ltu0>s|FLsT+Iy7K~ z!6*Z0a@vQ;AiZo!=s{{fqR+ct6YQPzbk+j}*qe7vtu39I7 zrOtZqU}=NnLchJxsU9iY+}3TYDl|BvPsX%E@dlyLgdV%q$UP|Y?DfcGb`}K&$;drd z+hL;zy7UTccUYU+h`ONIU|d=%`(0$=KW4%tVWXj~AE 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) diff --git a/docs/source/sphinx_modules/sphinx_ext_autosummary_reworked.py b/docs/source/sphinx_modules/sphinx_ext_autosummary_reworked.py index 8224690d..6561248b 100644 --- a/docs/source/sphinx_modules/sphinx_ext_autosummary_reworked.py +++ b/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) diff --git a/docs/source/static/theme_overrides.css b/docs/source/static/theme_overrides.css index b8084ed1..39d76d68 100644 --- a/docs/source/static/theme_overrides.css +++ b/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 */ diff --git a/docs/source/templates/custom-class-template.01.rst b/docs/source/templates/custom-class-template.01.rst index 2d79aca6..e5063d83 100644 --- a/docs/source/templates/custom-class-template.01.rst +++ b/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 ` ------------------------------- + {% 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 %} + + diff --git a/docs/source/templates/custom-module-template.01.rst b/docs/source/templates/custom-module-template.01.rst index baeaca15..bc3851c4 100644 --- a/docs/source/templates/custom-module-template.01.rst +++ b/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: diff --git a/tutorial/003-signalslots.rst b/tutorial/003-signalslots.rst index e1df423a..0363de62 100644 --- a/tutorial/003-signalslots.rst +++ b/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 =====