1616from NodeGraphQt .base .port import Port
1717from NodeGraphQt .constants import (DRAG_DROP_ID ,
1818 PIPE_LAYOUT_CURVED ,
19- PIPE_LAYOUT_STRAIGHT , PIPE_LAYOUT_ANGLE )
19+ PIPE_LAYOUT_STRAIGHT ,
20+ PIPE_LAYOUT_ANGLE ,
21+ IN_PORT , OUT_PORT )
2022from NodeGraphQt .widgets .viewer import NodeViewer
2123
2224
@@ -25,21 +27,21 @@ class NodeGraph(QtCore.QObject):
2527 base node graph controller.
2628 """
2729
28- #: (signal) emits the node object when a node is created in the node graph.
30+ #:QtCore.Signal: emits the node object when a node is created in the node graph.
2931 node_created = QtCore .Signal (NodeObject )
30- #: (signal) emits a list of node ids from the deleted nodes.
32+ #:QtCore.Signal: emits a `` list[str]`` of node ids from the deleted nodes.
3133 nodes_deleted = QtCore .Signal (list )
32- #: (signal) emits the node object when selected in the node graph.
34+ #:QtCore.Signal: emits the node object when selected in the node graph.
3335 node_selected = QtCore .Signal (NodeObject )
34- #: (signal) triggered when a node is double clicked and emits the node.
36+ #:QtCore.Signal: triggered when a node is double clicked and emits the node.
3537 node_double_clicked = QtCore .Signal (NodeObject )
36- #: (signal) for when a node has been connected emits (source port, target port).
38+ #:QtCore.Signal: for when a node has been connected emits (``input port``, ``output port`` ).
3739 port_connected = QtCore .Signal (Port , Port )
38- #: (signal) for when a node has been disconnected emits (source port, target port).
40+ #:QtCore.Signal: for when a node has been disconnected emits (``input port``, ``output port`` ).
3941 port_disconnected = QtCore .Signal (Port , Port )
40- #: (signal) for when a node property has changed emits (node, property name, property value).
42+ #:QtCore.Signal: for when a node property has changed emits (`` node``, `` property name``, `` property value`` ).
4143 property_changed = QtCore .Signal (NodeObject , str , object )
42- #: (signal) for when drop data has been added to the graph.
44+ #:QtCore.Signal: for when drop data has been added to the graph.
4345 data_dropped = QtCore .Signal (QtCore .QMimeData , QtCore .QPoint )
4446
4547 def __init__ (self , parent = None ):
@@ -177,7 +179,7 @@ def _on_connection_changed(self, disconnected, connected):
177179 return
178180
179181 label = 'connect node(s)' if connected else 'disconnect node(s)'
180- ptypes = {'in' : 'inputs' , 'out' : 'outputs' }
182+ ptypes = {IN_PORT : 'inputs' , OUT_PORT : 'outputs' }
181183
182184 self ._undo_stack .beginMacro (label )
183185 for p1_view , p2_view in disconnected :
@@ -204,7 +206,7 @@ def _on_connection_sliced(self, ports):
204206 """
205207 if not ports :
206208 return
207- ptypes = {'in' : 'inputs' , 'out' : 'outputs' }
209+ ptypes = {IN_PORT : 'inputs' , OUT_PORT : 'outputs' }
208210 self ._undo_stack .beginMacro ('slice connections' )
209211 for p1_view , p2_view in ports :
210212 node1 = self ._model .nodes [p1_view .node .id ]
@@ -242,14 +244,14 @@ def widget(self):
242244 def show (self ):
243245 """
244246 Show node graph widget this is just a convenience
245- function to :meth:`NodeGraphQt. NodeGraph.widget.show()`.
247+ function to :meth:`NodeGraph.widget() .show()`.
246248 """
247249 self ._widget .show ()
248250
249251 def close (self ):
250252 """
251253 Close node graph NodeViewer widget this is just a convenience
252- function to :meth:`NodeGraphQt. NodeGraph.widget.close()`.
254+ function to :meth:`NodeGraph.widget() .close()`.
253255 """
254256 self ._widget .close ()
255257
@@ -356,7 +358,7 @@ def clear_undo_stack(self):
356358
357359 Note:
358360 Convenience function to
359- :meth:`NodeGraphQt. NodeGraph.undo_stack().clear`
361+ :meth:`NodeGraph.undo_stack().clear() `
360362
361363 See Also:
362364 :meth:`NodeGraph.begin_undo()`,
@@ -772,14 +774,16 @@ def _serialize(self, nodes):
772774 for pname , conn_data in inputs .items ():
773775 for conn_id , prt_names in conn_data .items ():
774776 for conn_prt in prt_names :
775- pipe = {'in' : [n_id , pname ], 'out' : [conn_id , conn_prt ]}
777+ pipe = {IN_PORT : [n_id , pname ],
778+ OUT_PORT : [conn_id , conn_prt ]}
776779 if pipe not in serial_data ['connections' ]:
777780 serial_data ['connections' ].append (pipe )
778781
779782 for pname , conn_data in outputs .items ():
780783 for conn_id , prt_names in conn_data .items ():
781784 for conn_prt in prt_names :
782- pipe = {'out' : [n_id , pname ], 'in' : [conn_id , conn_prt ]}
785+ pipe = {OUT_PORT : [n_id , pname ],
786+ IN_PORT : [conn_id , conn_prt ]}
783787 if pipe not in serial_data ['connections' ]:
784788 serial_data ['connections' ].append (pipe )
785789
0 commit comments