Skip to content

Commit 765e63e

Browse files
committed
added properties bin example
1 parent 1bd4cc7 commit 765e63e

File tree

1 file changed

+58
-3
lines changed

1 file changed

+58
-3
lines changed

docs/examples/ex_node.rst

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ connecting nodes with the port objects:
6767
port_a.connect_to(port_b)
6868
6969
70-
See functions:
70+
more on ports and connections:
7171
- :func:`NodeGraphQt.BaseNode.input`,
7272
- :func:`NodeGraphQt.BaseNode.output`
7373
- :func:`NodeGraphQt.BaseNode.set_input`,
@@ -78,6 +78,61 @@ See functions:
7878
- :func:`NodeGraphQt.Port.disconnect_from`
7979

8080

81-
Properties Bin Setup
82-
********************
81+
Widget Example
82+
**************
83+
84+
Here's an example where we subclass the ``NodeGraph`` and connect it up to a
85+
``PropertiesBinWidget`` and have it show when a node is double clicked.
86+
87+
.. code-block:: python
88+
:linenos:
89+
90+
from NodeGraphQt import BaseNode, NodeGraph, PropertiesBinWidget, QtCore, QtWidgets
91+
92+
93+
class MyNode(BaseNode):
94+
95+
__identifier__ = 'com.chantasticvfx'
96+
NODE_NAME = 'my node'
97+
98+
def __init__(self):
99+
super(MyNode, self).__init__()
100+
self.add_input('in')
101+
self.add_output('out')
102+
103+
104+
class MyNodeGraph(NodeGraph):
105+
106+
def __init__(self, parent=None):
107+
super(MyNodeGraph, self).__init__(parent)
108+
109+
# properties bin widget.
110+
self._prop_bin = PropertiesBinWidget(node_graph=self)
111+
self._prop_bin.setWindowFlags(QtCore.Qt.Tool)
112+
113+
# wire signal.
114+
self.node_double_clicked.connect(self.display_prop_bin)
115+
116+
def display_prop_bin(self, node):
117+
"""
118+
function for displaying the properties bin when a node
119+
is double clicked
120+
"""
121+
if not self._prop_bin.isVisible():
122+
self._prop_bin.show()
123+
124+
125+
if __name__ == '__main__':
126+
app = QtWidgets.QApplication([])
127+
128+
node_graph = MyNodeGraph()
129+
node_graph.register_node(MyNode)
130+
node_graph.widget.show()
131+
132+
node_a = node_graph.create_node('com.chantasticvfx.MyNode')
133+
134+
app.exec_()
83135
136+
more on the properties bin and node_double_clicked signal:
137+
- :class:`NodeGraphQt.PropertiesBinWidget`
138+
- :attr:`NodeGraphQt.NodeGraph.node_double_clicked`

0 commit comments

Comments
 (0)