diff --git a/TermTk/TTkWidgets/texedit.py b/TermTk/TTkWidgets/texedit.py index 8e0aacd3..29b34e5d 100644 --- a/TermTk/TTkWidgets/texedit.py +++ b/TermTk/TTkWidgets/texedit.py @@ -136,6 +136,7 @@ class TTkTextEditView(TTkAbstractScrollView): self._updateSize() def multiLine(self) -> bool : + '''multiline''' return self._multiLine @pyTTkSlot(bool) @@ -157,34 +158,41 @@ class TTkTextEditView(TTkAbstractScrollView): # return "" def toAnsi(self): + '''toAnsi''' if self._textDocument: return self._textDocument.toAnsi() return "" def toPlainText(self): + '''toPlainText''' if self._textDocument: return self._textDocument.toPlainText() return "" def toRawText(self): + '''toRawText''' if self._textDocument: return self._textDocument.toRawText() return TTkString() def isUndoAvailable(self): + '''isUndoAvailable''' if self._textDocument: return self._textDocument.isUndoAvailable() return False def isRedoAvailable(self): + '''isRedoAvailable''' if self._textDocument: return self._textDocument.isRedoAvailable() return False def document(self): + '''document''' return self._textDocument def setDocument(self, document): + '''setDocument''' if self._textDocument: self._textDocument.contentsChanged.disconnect(self._documentChanged) self._textDocument.cursorPositionChanged.disconnect(self._cursorPositionChanged) @@ -573,7 +581,76 @@ class TTkTextEditView(TTkAbstractScrollView): self._pushCursor() class TTkTextEdit(TTkAbstractScrollArea): - '''TTkTextEdit''' + '''TTkTextEdit + + :: + + ╔═══════════════════════════════════════════════════════════════════════════════════════╗ + ║ 0▌"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor ╥ ║ + ║ <▌incididunt ut labore et dolore magna aliqua. ║ ║ + ║ 1▌ ║ ║ + ║ 2▌Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliqu║ ║ + ║ <▌ip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate ║ ║ + ║ <▌velit esse cillum dolore eu fugiat nulla pariatur. ║ ║ + ║ 3▌ ║ ║ + ║ 4▌Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deseru║ ║ + ║ <▌nt mollit anim id est laborum." ╨ ║ + ╚═══════════════════════════════════════════════════════════════════════════════════════╝ + + Demo: `textedit.py `_ + (`Try Online `__) + + `ttkdesigner Tutorial `_ + + + :param lineNumber: Show the line number on the left, defaults to **False** + :type lineNumber: bool, optional + + :param readOnly: In a read-only text edit the user can only navigate through the text and select text; modifying the text is not possible, defaults to **True** + :type readOnly: bool, optional + + :param multiLine: In a multiline text edit the user can split the text in multiple lines, defaults to **True** + :type multiLine: bool, optional + + :param document: If required an external Document can be used in this text editor, this option is useful if multiple editors share the same document as in the `demo `__, defaults to a new Document + :type document: :class:`~TermTk.TermTk.TTkGui.textdocument.TTkTextDocument`, optional + + +-----------------------------------------------------------------------------------------------+ + | `Signals `_ | + +-----------------------------------------------------------------------------------------------+ + + .. py:method:: currentColorChanged(color) + :signal: + + This signal is emitted if the current character color has changed, for example caused by a change of the cursor position. + + :param color: the new color + :type color: :class:`~TermTk.TermTk.TTkCore.color.TTkColor` + + .. py:method:: undoAvailable(available) + :signal: + + This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false). + + :param available: the availability of undo + :type available: bool + + .. py:method:: redoAvailable(available) + :signal: + + This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false). + + :param available: the availability of redo + :type available: bool + + .. py:method:: textChanged() + :signal: + + This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied. + + .. py:method:: toAnsi() + + ''' __slots__ = ( '_textEditView', '_lineNumberView', '_lineNumber', diff --git a/TermTk/TTkWidgets/widget.py b/TermTk/TTkWidgets/widget.py index 00b4b329..80c57960 100644 --- a/TermTk/TTkWidgets/widget.py +++ b/TermTk/TTkWidgets/widget.py @@ -570,6 +570,7 @@ class TTkWidget(TMouseEvents,TKeyEvents, TDragEvents): @pyTTkSlot() def show(self): + '''show''' if self._visible: return self._visible = True self._canvas.show() @@ -579,6 +580,7 @@ class TTkWidget(TMouseEvents,TKeyEvents, TDragEvents): @pyTTkSlot() def hide(self): + '''hide''' if not self._visible: return self._visible = False self._canvas.hide() @@ -586,6 +588,7 @@ class TTkWidget(TMouseEvents,TKeyEvents, TDragEvents): @pyTTkSlot() def raiseWidget(self, raiseParent=True): + '''raiseWidget''' if self._parent is not None and \ self._parent.rootLayout() is not None: if raiseParent: @@ -594,6 +597,7 @@ class TTkWidget(TMouseEvents,TKeyEvents, TDragEvents): @pyTTkSlot() def lowerWidget(self): + '''lowerWidget''' if self._parent is not None and \ self._parent.rootLayout() is not None: self._parent.lowerWidget() @@ -601,6 +605,7 @@ class TTkWidget(TMouseEvents,TKeyEvents, TDragEvents): @pyTTkSlot() def close(self): + '''close''' if self._parent is not None and \ self._parent.rootLayout() is not None: self._parent.rootLayout().removeWidget(self) @@ -611,6 +616,7 @@ class TTkWidget(TMouseEvents,TKeyEvents, TDragEvents): @pyTTkSlot(bool) def setVisible(self, visible: bool): + '''setVisible''' if visible: self.show() else: self.hide() @@ -639,6 +645,7 @@ class TTkWidget(TMouseEvents,TKeyEvents, TDragEvents): @pyTTkSlot() def setFocus(self): + '''setFocus''' # TTkLog.debug(f"setFocus: {self._name} - {self._focus}") if self._focus and self == TTkHelper.getFocus(): return tmp = TTkHelper.getFocus() @@ -683,12 +690,14 @@ class TTkWidget(TMouseEvents,TKeyEvents, TDragEvents): @pyTTkSlot(bool) def setEnabled(self, enabled: bool=True): + '''setEnabled''' if self._enabled == enabled: return self._enabled = enabled self.update() @pyTTkSlot(bool) def setDisabled(self, disabled=True): + '''setDisabled''' self.setEnabled(not disabled) def lookAndFeel(self): diff --git a/demo/showcase/textedit.py b/demo/showcase/textedit.py index 75685d21..540c3928 100755 --- a/demo/showcase/textedit.py +++ b/demo/showcase/textedit.py @@ -59,9 +59,10 @@ def demoTextEdit(root=None, document=None): te.setText(ttk.TTkString("Text Edit DEMO\n",ttk.TTkColor.UNDERLINE+ttk.TTkColor.BOLD+ttk.TTkColor.ITALIC)) # Load ANSI input - te.append(ttk.TTkString("ANSI Input Test\n",ttk.TTkColor.UNDERLINE+ttk.TTkColor.BOLD)) - with open(os.path.join(os.path.dirname(os.path.abspath(__file__)),'textedit.ANSI.txt')) as f: - te.append(f.read()) + if os.path.exists(os.path.join(os.path.dirname(os.path.abspath(__file__)),'textedit.ANSI.txt')): + te.append(ttk.TTkString("ANSI Input Test\n",ttk.TTkColor.UNDERLINE+ttk.TTkColor.BOLD)) + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)),'textedit.ANSI.txt')) as f: + te.append(f.read()) # Test Variable sized chars te.append(ttk.TTkString("Test Variable sized chars\n",ttk.TTkColor.UNDERLINE+ttk.TTkColor.BOLD)) diff --git a/docs/source/conf.py b/docs/source/conf.py index edeadedf..23209d28 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -126,14 +126,15 @@ autodocgen_config = { 'write_documented_items_output_file': 'autodocgen_documented_items.txt', # customize autodoc on a per-module basis - 'autodoc_options_decider': { - 'TermTk.TTkWidgets': { 'inherited-members':True }, - }, + 'autodoc_options_decider': {}, # choose a different title for specific modules, e.g. the toplevel one #'module_title_decider': lambda modulename: 'API Reference' if modulename=='TermTk' else modulename, } +# autodoc_default_options = { 'inherited-members':True } +autodoc_default_options = {} + # Mock pyodide to avoid autogen failure class pyodideProxy(): pass moduleInput = type(sys)('pyodideProxy') diff --git a/docs/source/index.rst b/docs/source/index.rst index d29f5159..9417c08c 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -49,6 +49,7 @@ Intro autogen.TermTk/TermTk.TTkTestWidgets.rst autogen.TermTk/TermTk.TTkTheme.rst autogen.TermTk/TermTk.TTkTypes.rst + autogen.TermTk/TermTk.TTkUiTools.rst autogen.TermTk/TermTk.TTkWidgets.rst autogen.TermTk/TermTk.TTkWidgets.TTkModelView.rst autogen.TermTk/TermTk.TTkWidgets.TTkPickers.rst diff --git a/tutorial/ttkDesigner/textEdit/README.rst b/tutorial/ttkDesigner/textEdit/README.rst index b01cabd5..d15dbe8a 100644 --- a/tutorial/ttkDesigner/textEdit/README.rst +++ b/tutorial/ttkDesigner/textEdit/README.rst @@ -2,6 +2,20 @@ .. _TermTk: https://github.com/ceccopierangiolieugenio/pyTermTk .. _ttkDesigner: https://github.com/ceccopierangiolieugenio/pyTermTk/tree/main/ttkDesigner +.. _Widget: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.widget.html +.. _Textedit: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.texedit.html +.. _window: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.window.html +.. _button: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.button.html +.. _buttons: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkWidgets.button.html + +.. _layout: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkLayouts.html +.. _TTkLayouts: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkLayouts.html +.. _TTkLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkLayouts.layout.html#ttklayout +.. _TTkHBoxLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkLayouts.boxlayout.html#ttkhboxlayout +.. _TTkVBoxLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkLayouts.boxlayout.html#ttkvboxlayout +.. _grid: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkLayouts.gridlayout.html#ttkgridlayout +.. _TTkGridLayout: https://ceccopierangiolieugenio.github.io/pyTermTk/autogen.TermTk/TermTk.TTkLayouts.gridlayout.html#ttkgridlayout + =================== ttkDesigner_ - Your first TextEditor =================== @@ -10,6 +24,16 @@ ttkDesigner_ - Your first TextEditor Start a new project =================== +- Create a new Window (**File** -> **New** -> **New Window**) +- Set the window params required: + + - Resize + - title + - Name - (This is the unique name that will be used to identify this Widget_) + - Window flags (i.e. Maximize) + - Layout to TTkGridLayout_ (This will allow all the components to be placed in a grid aligned to the content of the window_) + - Add the "Maximize Button" through the Window Flags (I forgot to add this step in the video) + .. raw:: html