diff --git a/TermTk/TTkWidgets/TTkPickers/filepicker.py b/TermTk/TTkWidgets/TTkPickers/filepicker.py index f68f1d9b..9c0e268b 100644 --- a/TermTk/TTkWidgets/TTkPickers/filepicker.py +++ b/TermTk/TTkWidgets/TTkPickers/filepicker.py @@ -88,8 +88,7 @@ class TTkFileDialogPicker(TTkWindow): ║Files of type:[All Files (*) ^][Cancel]║ ╚═════════════════════════════════════════════════════════════════════════╝ - Demo: `filepicker.py `_ - (`Try Online `__) + Demo: :ttk:sbIntLink:`demo/showcase,filepicker.py` :ref:`ttkdesigner Tutorial ` @@ -413,8 +412,7 @@ class TTkFileButtonPicker(TTkButton): ║Files of type:[All Files (*) ^][Cancel]║ ╚═════════════════════════════════════════════════════════════════════════╝ - Demo: `filepicker.py `_ - (`Try Online `__) + Demo: :ttk:sbIntLink:`demo/showcase,filepicker.py` :param path: the current path used in the file dialog, defaults to "." :type path: str, optional diff --git a/TermTk/TTkWidgets/texedit.py b/TermTk/TTkWidgets/texedit.py index f2abc9ae..415335b4 100644 --- a/TermTk/TTkWidgets/texedit.py +++ b/TermTk/TTkWidgets/texedit.py @@ -122,8 +122,7 @@ class TTkTextEditView(TTkAbstractScrollView): ║ <▌nt mollit anim id est laborum." ╨ ║ ╚═══════════════════════════════════════════════════════════════════════════════════════╝ - Demo: `textedit.py `_ - (`Try Online `__) + Demo: :ttk:sbIntLink:`demo/showcase,textedit.py` :ref:`ttkdesigner Tutorial ` ''' @@ -213,7 +212,7 @@ class TTkTextEditView(TTkAbstractScrollView): :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 + :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: :py:class:`TTkTextDocument`, optional ''' diff --git a/docs/source/conf.py b/docs/source/conf.py index 42a47a60..36031443 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -46,6 +46,7 @@ extensions = [ 'sphinx_ext_autosummary_reworked', # Create neat summary tables 'sphinx_PyRefRole_hacked', # Resolve Domainless TermTk Classes 'method_signal', + 'sandbox_links', ] templates_path = ['templates'] diff --git a/docs/source/info/installing.rst b/docs/source/info/installing.rst index a668ccfe..6c702ac5 100644 --- a/docs/source/info/installing.rst +++ b/docs/source/info/installing.rst @@ -95,9 +95,9 @@ Clone or `Download `_ (`tryItOnline `__) -* paint demo `paint.py `_ (`tryItOnline `__) -* ttkode prototype `ttkode.py `_ (`tryItOnline `__) +* Main demo :ttk:sbIntLink:`demo,demo.py` +* paint demo :ttk:sbIntLink:`demo,paint.py` +* ttkode prototype :ttk:sbIntLink:`demo,ttkode.py` .. code:: bash @@ -116,19 +116,19 @@ Showcase **Highlight:** -* Text Editor `textedit.py `_ (`tryItOnline `__) -* Animation `animation.01.py `_ (`tryItOnline `__) -* color picker `colorpicker.py `_ (`tryItOnline `__) -* file picker `filepicker.py `_ (`tryItOnline `__) -* drag & drop `dragndrop.py `_ (`tryItOnline `__) -* d&d with tabs `dndtabs.py `_ (`tryItOnline `__) -* d&d with list `list.py `_ (`tryItOnline `__) -* base widgets `formwidgets02.py `_ (`tryItOnline `__) -* messagebox `messagebox.py `_ (`tryItOnline `__) -* splitter `splitter.py `_ (`tryItOnline `__) -* Windows `windowsflags.py `_ (`tryItOnline `__) -* AppTemplate `apptemplate.py `_ (`tryItOnline `__) -* Tooltip `test.ui.026.toolTip.py `_ (`tryItOnline `__) +* Text Editor :ttk:sbIntLink:`demo/showcase,textedit.py` +* Animation :ttk:sbIntLink:`demo/showcase,animation.01.py` +* color picker :ttk:sbIntLink:`demo/showcase,colorpicker.py` +* file picker :ttk:sbIntLink:`demo/showcase,filepicker.py` +* drag & drop :ttk:sbIntLink:`demo/showcase,dragndrop.py` +* d&d with tabs :ttk:sbIntLink:`demo/showcase,dndtabs.py` +* d&d with list :ttk:sbIntLink:`demo/showcase,list.py` +* base widgets :ttk:sbIntLink:`demo/showcase,formwidgets02.py` +* messagebox :ttk:sbIntLink:`demo/showcase,messagebox.py` +* splitter :ttk:sbIntLink:`demo/showcase,splitter.py` +* Windows :ttk:sbIntLink:`demo/showcase,windowsflags.py` +* AppTemplate :ttk:sbIntLink:`demo/showcase,apptemplate.py` +* ToolTip :ttk:sbIntLink:`tests/t.ui,test.ui.026.toolTip.py` .. code:: bash diff --git a/docs/source/info/resources/dragdrop.rst b/docs/source/info/resources/dragdrop.rst index a308a35f..cc696026 100644 --- a/docs/source/info/resources/dragdrop.rst +++ b/docs/source/info/resources/dragdrop.rst @@ -57,7 +57,7 @@ Note that the :py:meth:`TTkDrag.exec` function does not block the main event loo .. seealso:: - * `tutorial/examples/DragAndDrop/dnd.01.basic.py `__ (`tryItOnline `__) + * :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.01.basic.py` -------- Dropping @@ -74,7 +74,7 @@ the :py:meth:`TDragEvents.dropEvent` event handler functions. .. seealso:: - * `tutorial/examples/DragAndDrop/dnd.01.basic.py `__ (`tryItOnline `__) + * :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.01.basic.py` ------ @@ -108,8 +108,8 @@ There are several events that can be used to customize the drag and drop operati .. seealso:: - * `tutorial/examples/DragAndDrop/dnd.02.events.01.py `__ (`tryItOnline `__) - * `tutorial/examples/DragAndDrop/dnd.02.events.02.py `__ (`tryItOnline `__) + * :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.02.events.01.py` + * :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.02.events.02.py` ------ @@ -164,10 +164,10 @@ Or use a :py:class:`TTkCanvas` as pixmap and draw the required content on it: .. seealso:: - * `tutorial/examples/DragAndDrop/dnd.03.pixmap.01.py `__ (`tryItOnline `__) - * `tutorial/examples/DragAndDrop/dnd.03.pixmap.02.py `__ (`tryItOnline `__) - * `tutorial/examples/DragAndDrop/dnd.03.pixmap.03.py `__ (`tryItOnline `__) - * `tutorial/examples/DragAndDrop/dnd.03.pixmap.04.py `__ (`tryItOnline `__) + * :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.03.pixmap.01.py` + * :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.03.pixmap.02.py` + * :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.03.pixmap.03.py` + * :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.03.pixmap.04.py` ------- @@ -192,17 +192,17 @@ the object being dragged from the clicked position: .. seealso:: - * `tutorial/examples/DragAndDrop/dnd.04.hotSpot.01.py `__ (`tryItOnline `__) + * :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.04.hotSpot.01.py` -------- Examples -------- -* `tutorial/examples/DragAndDrop/dnd.01.basic.py `__ (`tryItOnline `__) -* `tutorial/examples/DragAndDrop/dnd.02.events.01.py `__ (`tryItOnline `__) -* `tutorial/examples/DragAndDrop/dnd.02.events.02.py `__ (`tryItOnline `__) -* `tutorial/examples/DragAndDrop/dnd.03.pixmap.01.py `__ (`tryItOnline `__) -* `tutorial/examples/DragAndDrop/dnd.03.pixmap.02.py `__ (`tryItOnline `__) -* `tutorial/examples/DragAndDrop/dnd.03.pixmap.03.py `__ (`tryItOnline `__) -* `tutorial/examples/DragAndDrop/dnd.04.pixmap.03.py `__ (`tryItOnline `__) -* `tutorial/examples/DragAndDrop/dnd.04.hotSpot.01.py `__ (`tryItOnline `__) +* :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.01.basic.py` +* :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.02.events.01.py` +* :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.02.events.02.py` +* :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.03.pixmap.01.py` +* :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.03.pixmap.02.py` +* :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.03.pixmap.03.py` +* :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.03.pixmap.04.py` +* :ttk:sbIntLink:`tutorial/examples/DragAndDrop/dnd.04.hotSpot.01.py` diff --git a/docs/source/sphinx_modules/sandbox_links.py b/docs/source/sphinx_modules/sandbox_links.py new file mode 100644 index 00000000..2c0603a5 --- /dev/null +++ b/docs/source/sphinx_modules/sandbox_links.py @@ -0,0 +1,110 @@ +"""Sphinx extension to handle the signal directive in the method.""" + +__version__ = '2024.10' + +from typing import get_overloads +from typing import TYPE_CHECKING, Any, ClassVar, NamedTuple, cast + +from sphinx.util.inspect import signature, stringify_signature + +from sphinx import addnodes +from docutils import nodes +from docutils.parsers.rst import directives +from sphinx.domains.python import PyMethod, PyObject + +if True or TYPE_CHECKING: + from collections.abc import Sequence + + from docutils.nodes import Node, system_message + + from sphinx.application import Sphinx + from sphinx.extension import Extension + from sphinx.util.typing import ExtensionMetadata, OptionSpec + from sphinx.writers.html5 import HTML5Translator + +def demo_link_role_int(name, rawtext, text, lineno, inliner, options={}, content=[]): + """ + Custom role to generate GitHub and TryItOnline links with optional prefix removal. + """ + base_github_url = "https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/" + + # Split text into prefix and actual file path + + file_name = text.split(',')[-1].strip() + file_path = '/'.join([s.strip() for s in text.split(',')]) + + # Generate GitHub and TryItOnline links + github_url = f"{base_github_url}{file_path.strip()}" + + # Format the output + paragraph_node = nodes.inline() + github_link = nodes.reference(rawtext, file_name , refuri=github_url, **options) + + # Add links and combine + paragraph_node += github_link + + return [paragraph_node], [] + +def demo_link_role_int_sb(name, rawtext, text, lineno, inliner, options={}, content=[]): + """ + Custom role to generate GitHub and TryItOnline links with optional prefix removal. + """ + base_github_url = "https://github.com/ceccopierangiolieugenio/pyTermTk/blob/main/" + base_tio_url = "https://ceccopierangiolieugenio.github.io/pyTermTk/sandbox/sandbox.html?filePath=" + + # Split text into prefix and actual file path + + file_name = text.split(',')[-1].strip() + file_path = '/'.join([s.strip() for s in text.split(',')]) + + # Generate GitHub and TryItOnline links + github_url = f"{base_github_url}{file_path.strip()}" + tio_url = f"{base_tio_url}{file_path.strip()}" + + # Format the output + paragraph_node = nodes.inline() + github_link = nodes.reference(rawtext, file_name , refuri=github_url, **options) + tio_link = nodes.reference(rawtext, "tryItOnline", refuri=tio_url , **options) + + # Add links and combine + paragraph_node += github_link + paragraph_node += nodes.Text(" ") + paragraph_node += nodes.Text("(") + paragraph_node += tio_link + paragraph_node += nodes.Text(")") + + return [paragraph_node], [] + +def demo_link_role_ext_sb(name, rawtext, text, lineno, inliner, options={}, content=[]): + """ + Custom role to generate GitHub and TryItOnline links with optional prefix removal. + """ + base_tio_url = "https://ceccopierangiolieugenio.github.io/pyTermTk/sandbox/sandbox.html?fileUri=" + + # Split text into prefix and actual file path + + file_name = text.split(',')[-1].strip() + file_uri = '/'.join([s.strip() for s in text.split(',')]) + + # Generate GitHub and TryItOnline links + tio_url = f"{base_tio_url}{file_uri.strip()}" + + # Format the output + paragraph_node = nodes.inline() + github_link = nodes.reference(rawtext, file_name , refuri=file_uri, **options) + tio_link = nodes.reference(rawtext, "tryItOnline", refuri=tio_url , **options) + + # Add links and combine + paragraph_node += github_link + paragraph_node += nodes.Text(" ") + paragraph_node += nodes.Text("(") + paragraph_node += tio_link + paragraph_node += nodes.Text(")") + + return [paragraph_node], [] + +# Register the custom role +def setup(app): + app.add_role("ttk:ghIntLink", demo_link_role_int) + app.add_role("ttk:sbIntLink", demo_link_role_int_sb) + app.add_role("ttk:sbExtLink", demo_link_role_ext_sb) \ No newline at end of file diff --git a/tutorial/000-examples.rst b/tutorial/000-examples.rst index 0a5ed0b1..bb0f3cd3 100644 --- a/tutorial/000-examples.rst +++ b/tutorial/000-examples.rst @@ -11,8 +11,7 @@ TTkLineEdit Init ---- -`TTkLineEdit/Init.01.py `__ - -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkLineEdit/Init.01.py`: .. code:: bash @@ -24,8 +23,7 @@ Init Set/Get Text ------------ -`TTkLineEdit/SetGet.01.py `__ - -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkLineEdit/SetGet.01.py`: .. code:: bash @@ -37,8 +35,7 @@ Set/Get Text Events ------ -`TTkLineEdit/SetGet.01.py `__ - -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkLineEdit/Events.01.py` .. _Examples-Terminal: @@ -48,69 +45,58 @@ TTkTerminal .. note:: This widget is available only on Linux/Mac -`TTkTerminal/TerminalTab.01.Basic.py `__ +:ttk:ghIntLink:`tutorial/examples,TTkTerminal/TerminalTab.01.Basic.py` -`TTkTerminal/TerminalTab.02.AddButton.py `__ +:ttk:ghIntLink:`tutorial/examples,TTkTerminal/TerminalTab.02.AddButton.py` -`TTkTerminal/TerminalTab.03.KodeTab.py `__ +:ttk:ghIntLink:`tutorial/examples,TTkTerminal/TerminalTab.03.KodeTab.py` -`TTkTerminal/TerminalTab.04.KodeTab.close.py `__ +:ttk:ghIntLink:`tutorial/examples,TTkTerminal/TerminalTab.04.KodeTab.close.py` TTkTable ======== -`TTkTable/table.01.basic.py `__ -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkTable/table.01.basic.py` -`TTkTable/table.02.custom.model.01.py `__ -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkTable/table.02.custom.model.01.py` -`TTkTable/table.02.custom.model.02.py `__ -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkTable/table.02.custom.model.02.py` -`TTkTable/table.02.custom.model.03.py `__ -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkTable/table.02.custom.model.03.py` -`TTkTable/table.03.theming.color.01.py `__ -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkTable/table.03.theming.color.01.py` -`TTkTable/table.03.theming.color.02.py `__ -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkTable/table.03.theming.color.02.py` -`TTkTable/table.03.theming.color.03.py `__ -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkTable/table.03.theming.color.03.py` -`TTkTable/table.03.theming.headers.01.py `__ -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkTable/table.03.theming.headers.01.py` -`TTkTable/table.03.theming.lines.01.py `__ -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkTable/table.03.theming.lines.01.py` -`TTkTable/table.04.methods.py `__ -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkTable/table.04.methods.py` -`TTkTable/table.05.events.py `__ -(`tryItOnline `__): +:ttk:sbIntLink:`tutorial/examples,TTkTable/table.05.events.py` DragAndDrop =========== -`tutorial/examples/DragAndDrop/dnd.01.basic.py `__ (`tryItOnline `__) +:ttk:sbIntLink:`tutorial/examples,DragAndDrop/dnd.01.basic.py` -`tutorial/examples/DragAndDrop/dnd.02.events.01.py `__ (`tryItOnline `__) +:ttk:sbIntLink:`tutorial/examples,DragAndDrop/dnd.02.events.01.py` -`tutorial/examples/DragAndDrop/dnd.02.events.02.py `__ (`tryItOnline `__) +:ttk:sbIntLink:`tutorial/examples,DragAndDrop/dnd.02.events.02.py` -`tutorial/examples/DragAndDrop/dnd.03.pixmap.01.py `__ (`tryItOnline `__) +:ttk:sbIntLink:`tutorial/examples,DragAndDrop/dnd.03.pixmap.01.py` -`tutorial/examples/DragAndDrop/dnd.03.pixmap.02.py `__ (`tryItOnline `__) +:ttk:sbIntLink:`tutorial/examples,DragAndDrop/dnd.03.pixmap.02.py` -`tutorial/examples/DragAndDrop/dnd.03.pixmap.03.py `__ (`tryItOnline `__) +:ttk:sbIntLink:`tutorial/examples,DragAndDrop/dnd.03.pixmap.03.py` -`tutorial/examples/DragAndDrop/dnd.04.pixmap.03.py `__ (`tryItOnline `__) +:ttk:sbIntLink:`tutorial/examples,DragAndDrop/dnd.03.pixmap.04.py` -`tutorial/examples/DragAndDrop/dnd.04.hotSpot.01.py `__ (`tryItOnline `__) +:ttk:sbIntLink:`tutorial/examples,DragAndDrop/dnd.04.hotSpot.01.py`