Skip to content

Commit 1290ac8

Browse files
committed
Adjust ModuleNode.
1 parent 02bd457 commit 1290ac8

File tree

4 files changed

+18
-23
lines changed

4 files changed

+18
-23
lines changed

NodeGraphQt/base/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def undo_view(self):
394394
Returns node graph undo view.
395395
396396
Returns:
397-
PySide2.QtWidgets.QUndoView: node graph undo view.
397+
PySide2.QtWidgets.QUndoView: node graph undo view.
398398
"""
399399
if self._undo_view is None:
400400
self._undo_view = QtWidgets.QUndoView(self._undo_stack)

NodeGraphQt/base/port.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ def data_type(self):
221221
def data_type(self, data_type):
222222
self.__model.data_type = data_type
223223

224-
225224
@property
226225
def border_color(self):
227226
return self.__view.border_color

example_auto_nodes/module_nodes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def is_function(self, obj):
113113
return True
114114
return False
115115

116-
def get_numpy_args(self, func):
116+
@staticmethod
117+
def get_numpy_args(func):
117118
args = []
118119
info = numpydoc.docscrape.FunctionDoc(func)
119120
for i in info["Parameters"]:
@@ -122,7 +123,7 @@ def get_numpy_args(self, func):
122123
args.append(param.split("'")[1])
123124
return args
124125

125-
def addFunction(self, prop, func):
126+
def add_function(self, prop, func):
126127
"""
127128
Create inputs based on functions arguments.
128129
"""

example_auto_nodes/node_base/module_node.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def _get_functions_from_module(module, function_dict, max_depth=1, module_name=N
99
module_name = module.__name__
1010

1111
for func in funcs:
12-
if func in ["sys","os"]:
12+
if func in ["sys", "os"]:
1313
continue
1414

1515
new_module_name = module_name + "." + func
@@ -44,27 +44,28 @@ class ModuleNode(AutoNode):
4444

4545
module_functions = {}
4646

47-
def __init__(self,defaultInputType=None,defaultOutputType=None):
48-
super(ModuleNode, self).__init__(defaultInputType,defaultOutputType)
47+
def __init__(self, defaultInputType=None, defaultOutputType=None):
48+
super(ModuleNode, self).__init__(defaultInputType, defaultOutputType)
4949
self.add_combo_menu('funcs', 'Functions', items=list(self.module_functions.keys()))
50+
self.set_dynamic_port(True)
5051

5152
# switch math function type
52-
self.view.widgets['funcs'].value_changed.connect(self.addFunction)
53+
self.view.widgets['funcs'].value_changed.connect(self.add_function)
5354
self.add_output('output')
5455
self.create_property('output', None)
5556

5657
self.view.widgets['funcs'].widget.setCurrentIndex(0)
57-
self.addFunction(None, self.view.widgets['funcs'].widget.currentText())
58+
self.add_function(None, self.view.widgets['funcs'].widget.currentText())
5859

59-
def is_function(self,obj):
60+
def is_function(self, obj):
6061
if inspect.isfunction(self.func) or inspect.isbuiltin(self.func):
6162
return True
62-
elif "method" in type(obj).__name__ or "function" in type(obj).__name__:
63+
elif "method" in type(obj).__name__ or "function" in type(obj).__name__:
6364
return True
6465

6566
return False
6667

67-
def addFunction(self, prop, func):
68+
def add_function(self, prop, func):
6869
"""
6970
Create inputs based on functions arguments.
7071
"""
@@ -80,17 +81,14 @@ def addFunction(self, prop, func):
8081

8182
self.process_args(args)
8283

83-
def process_args(self,in_args, out_args = None):
84+
def process_args(self, in_args, out_args=None):
8485
for arg in in_args:
8586
if arg not in self.inputs().keys():
8687
self.add_input(arg)
8788

8889
for inPort in self.input_ports():
89-
if inPort.name() in in_args:
90-
if not inPort.visible():
91-
inPort.set_visible(True)
92-
else:
93-
inPort.set_visible(False)
90+
if inPort.name() not in in_args:
91+
self.delete_input(inPort)
9492

9593
if out_args is None:
9694
return
@@ -100,11 +98,8 @@ def process_args(self,in_args, out_args = None):
10098
self.add_output(arg)
10199

102100
for outPort in self.output_ports():
103-
if outPort.name() in out_args:
104-
if not outPort.visible():
105-
outPort.set_visible(True)
106-
else:
107-
outPort.set_visible(False)
101+
if outPort.name() not in out_args:
102+
self.delete_output(outPort)
108103

109104
def run(self):
110105
"""

0 commit comments

Comments
 (0)