Skip to content

Commit c2c30f6

Browse files
committed
small node and port clean up.
1 parent cc98ffa commit c2c30f6

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ docs/_build/
1212
# test stuff
1313
dist
1414
build
15+
16+
tests/*
17+
1518
*.egg-info
1619
*.json

NodeGraphQt/base/node.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,15 @@ def inputs(self):
529529
"""
530530
return {p.name(): p for p in self._inputs}
531531

532+
def input_ports(self):
533+
"""
534+
Return all input ports.
535+
536+
Returns:
537+
list[NodeGraphQt.Port]: node input ports.
538+
"""
539+
return self._inputs
540+
532541
def outputs(self):
533542
"""
534543
Returns all the output ports from the node.
@@ -538,6 +547,15 @@ def outputs(self):
538547
"""
539548
return {p.name(): p for p in self._outputs}
540549

550+
def output_ports(self):
551+
"""
552+
Return all output ports.
553+
554+
Returns:
555+
list[NodeGraphQt.Port]: node output ports.
556+
"""
557+
return self._outputs
558+
541559
def input(self, index):
542560
"""
543561
Return the input port with the matching index.

NodeGraphQt/base/port.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
PortDisconnectedCmd,
44
PortVisibleCmd)
55
from NodeGraphQt.base.model import PortModel
6+
from NodeGraphQt.constants import IN_PORT, OUT_PORT
67

78

89
class Port(object):
@@ -118,9 +119,9 @@ def connected_ports(self):
118119
for node_id, port_names in self.model.connected_ports.items():
119120
for port_name in port_names:
120121
node = graph.get_node_by_id(node_id)
121-
if self.type_() == 'in':
122+
if self.type_() == IN_PORT:
122123
ports.append(node.outputs()[port_name])
123-
elif self.type_() == 'out':
124+
elif self.type_() == OUT_PORT:
124125
ports.append(node.inputs()[port_name])
125126
return ports
126127

example.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33
import os
4-
import sys
54

65
from NodeGraphQt import (NodeGraph,
76
BaseNode,
@@ -34,7 +33,7 @@ def __init__(self):
3433

3534

3635
if __name__ == '__main__':
37-
app = QtWidgets.QApplication(sys.argv)
36+
app = QtWidgets.QApplication([])
3837

3938
# create node graph.
4039
graph = NodeGraph()

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
'supports PySide & PySide2'
1616
)
1717
classifiers = [
18-
'Programming Language :: Python :: 3.7',
19-
'License :: OSI Approved :: MIT License',
2018
'Operating System :: OS Independent',
19+
'License :: OSI Approved :: MIT License',
20+
'Programming Language :: Python :: 3.7',
2121
]
2222

2323
setuptools.setup(

0 commit comments

Comments
 (0)