@@ -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