Skip to content

Commit 54b7067

Browse files
committed
updated examples and docs
1 parent 3da0baa commit 54b7067

File tree

5 files changed

+88
-17
lines changed

5 files changed

+88
-17
lines changed

NodeGraphQt/base/graph.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ def acyclic(self):
505505
"""
506506
Returns true if the current node graph is acyclic.
507507
508+
See Also:
509+
:meth:`NodeGraphQt.NodeGraph.set_acyclic`
510+
508511
Returns:
509512
bool: true if acyclic (default: ``True``).
510513
"""
@@ -514,6 +517,9 @@ def set_acyclic(self, mode=False):
514517
"""
515518
Enable the node graph to be a acyclic graph. (default: ``False``)
516519
520+
See Also:
521+
:meth:`NodeGraphQt.NodeGraph.acyclic`
522+
517523
Args:
518524
mode (bool): true to enable acyclic.
519525
"""

NodeGraphQt/base/node.py

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,26 @@ def create_property(self, name, value, items=None, range=None,
232232
"""
233233
Creates a custom property to the node.
234234
235+
Widget Types:
236+
- :attr:`NodeGraphQt.constants.NODE_PROP`
237+
- :attr:`NodeGraphQt.constants.NODE_PROP_QLABEL`
238+
- :attr:`NodeGraphQt.constants.NODE_PROP_QLINEEDIT`
239+
- :attr:`NodeGraphQt.constants.NODE_PROP_QTEXTEDIT`
240+
- :attr:`NodeGraphQt.constants.NODE_PROP_QCOMBO`
241+
- :attr:`NodeGraphQt.constants.NODE_PROP_QCHECKBOX`
242+
- :attr:`NodeGraphQt.constants.NODE_PROP_QSPINBOX`
243+
- :attr:`NodeGraphQt.constants.NODE_PROP_COLORPICKER`
244+
- :attr:`NodeGraphQt.constants.NODE_PROP_SLIDER`
245+
246+
See Also:
247+
:class:`NodeGraphQt.PropertiesBinWidget`
248+
235249
Args:
236250
name (str): name of the property.
237251
value (object): data.
238252
items (list[str]): items used by widget type ``NODE_PROP_QCOMBO``
239253
range (tuple)): ``(min, max)`` values used by ``NODE_PROP_SLIDER``
240-
widget_type (int): widget flag to display in the properties bin.
254+
widget_type (int): widget flag to display in the ``PropertiesBinWidget``
241255
tab (str): name of the widget tab to display in the properties bin.
242256
"""
243257
self.model.add_property(name, value, items, range, widget_type, tab)
@@ -441,8 +455,13 @@ def icon(self):
441455

442456
def add_combo_menu(self, name='', label='', items=None, tab=None):
443457
"""
444-
Create a custom property and embed a
445-
:class:`PySide2.QtWidgets.QComboBox` widget into the node.
458+
Creates a custom property with the :meth:`NodeObject.create_property`
459+
function and embeds a :class:`PySide2.QtWidgets.QComboBox` widget
460+
into the node.
461+
462+
Note:
463+
The embedded widget is wired up to the :meth:`NodeObject.set_property`
464+
function use this function to to update the widget.
446465
447466
Args:
448467
name (str): name for the custom property.
@@ -460,8 +479,13 @@ def add_combo_menu(self, name='', label='', items=None, tab=None):
460479

461480
def add_text_input(self, name='', label='', text='', tab=None):
462481
"""
463-
Create a custom property and embed a
464-
:class:`PySide2.QtWidgets.QLineEdit` widget into the node.
482+
Creates a custom property with the :meth:`NodeObject.create_property`
483+
function and embeds a :class:`PySide2.QtWidgets.QLineEdit` widget
484+
into the node.
485+
486+
Note:
487+
The embedded widget is wired up to the :meth:`NodeObject.set_property`
488+
function use this function to to update the widget.
465489
466490
Args:
467491
name (str): name for the custom property.
@@ -477,8 +501,13 @@ def add_text_input(self, name='', label='', text='', tab=None):
477501

478502
def add_checkbox(self, name='', label='', text='', state=False, tab=None):
479503
"""
480-
Create a custom property and embed a
481-
:class:`PySide2.QtWidgets.QCheckBox` widget into the node.
504+
Creates a custom property with the :meth:`NodeObject.create_property`
505+
function and embeds a :class:`PySide2.QtWidgets.QCheckBox` widget
506+
into the node.
507+
508+
Note:
509+
The embedded widget is wired up to the :meth:`NodeObject.set_property`
510+
function use this function to to update the widget.
482511
483512
Args:
484513
name (str): name for the custom property.

docs/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,7 @@
210210

211211

212212
# -- Options for autodoc ----------------------------------------------------
213-
autodoc_member_order = 'groupwise'
213+
autodoc_member_order = 'groupwise'
214+
215+
# -- Options for image link -------------------------------------------------
216+
html_scaled_image_link = False

docs/examples/ex_node.rst

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Node Examples
44
Creating Nodes
55
**************
66

7-
| Creating is done simply by calling the :func:`NodeGraphQt.NodeGraph.create_node` function.
7+
| Creating a node is done by calling the :func:`NodeGraphQt.NodeGraph.create_node` function.
88
| (`see example below` ``line: 22``)
99
1010
.. code-block:: python
@@ -38,6 +38,44 @@ Creating Nodes
3838
app.exec_()
3939
4040
41+
Embedding Widgets
42+
*****************
43+
44+
The :meth:`NodeGraphQt.BaseNode` class allows you to embed widgets inside a node here's a
45+
example to simply embed a ``QComboBox`` widget when reimplementing the ``BaseNode``.
46+
47+
.. code-block:: python
48+
:linenos:
49+
50+
from NodeGraphQt import BaseNode
51+
52+
class MyListNode(BaseNode):
53+
54+
__identifier__ = 'com.chantasticvfx'
55+
NODE_NAME = 'node'
56+
57+
def __init__(self):
58+
super(MyListNode, self).__init__()
59+
60+
items = ['apples', 'bananas', 'pears', 'mangos', 'oranges']
61+
self.add_combo_menu('my_list', 'My List', items)
62+
63+
To you update the widget you can call the :meth:`NodeGraphQt.NodeObject.set_property` function.
64+
65+
.. code-block:: python
66+
:linenos:
67+
68+
node = MyListNode()
69+
node.set_property('my_list', 'mangos')
70+
71+
72+
`functions for embedding widgets into a base node:`
73+
74+
- ``QComboBox``: :meth:`NodeGraphQt.BaseNode.add_combo_menu`
75+
- ``QCheckBox``: :meth:`NodeGraphQt.BaseNode.add_checkbox`
76+
- ``QLineEdit``: :meth:`NodeGraphQt.BaseNode.add_text_input`
77+
78+
4179
Connecting Nodes
4280
****************
4381

@@ -78,8 +116,8 @@ connecting nodes with the port objects:
78116
- :func:`NodeGraphQt.Port.disconnect_from`
79117

80118

81-
Widget Example
82-
**************
119+
Connecting a PropertiesBin
120+
**************************
83121

84122
Here's an example where we subclass the ``NodeGraph`` and connect it up to a
85123
``PropertiesBinWidget`` and have it show when a node is double clicked.

docs/nodes.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
Nodes
22
#####
33

4-
.. image:: _images/screenshot.png
5-
:width: 95%
6-
7-
----
8-
94
.. toctree::
10-
:caption: Contents
5+
:caption: Node Classes
116
:name: nodestoc
127
:maxdepth: 2
138

0 commit comments

Comments
 (0)