@@ -57,10 +57,10 @@ def __init__(self, node, node_gui, flow_view, design):
5757 self .node_gui .update_shape_triggered .connect (self .update_shape )
5858 self .node_gui .hide_unconnected_ports_triggered .connect (self .hide_unconnected_ports_triggered )
5959 self .node_gui .show_unconnected_ports_triggered .connect (self .show_unconnected_ports_triggered )
60- self .node_gui .input_added .connect (self .add_new_input )
61- self .node_gui .output_added .connect (self .add_new_output )
62- self .node_gui .input_removed .connect (self .remove_input )
63- self .node_gui .output_removed .connect (self .remove_output )
60+ self .node_gui .input_added .connect (self .on_node_input_added )
61+ self .node_gui .output_added .connect (self .on_node_output_added )
62+ self .node_gui .input_removed .connect (self .on_node_input_removed )
63+ self .node_gui .output_removed .connect (self .on_node_output_removed )
6464
6565 # FLAGS
6666 self .setFlags (
@@ -171,6 +171,10 @@ def set_tooltip(self, error_msg=None):
171171 self .setToolTip (html )
172172 self .setCursor (Qt .SizeAllCursor )
173173
174+ def on_node_input_added (self , node , index , inp : NodeInput ):
175+ insert = index if index == len (node .inputs ) - 1 else None
176+ self .add_new_input (inp , insert )
177+
174178 def add_new_input (self , inp : NodeInput , insert : int = None ):
175179
176180 if inp in self .node_gui .input_widgets :
@@ -195,6 +199,9 @@ def add_new_input(self, inp: NodeInput, insert: int = None):
195199 self .update_shape ()
196200 self .update ()
197201
202+ def on_node_input_removed (self , node , index , inp : NodeInput ):
203+ self .remove_input (inp )
204+
198205 def remove_input (self , inp : NodeInput ):
199206 item = None
200207 for inp_item in self .inputs :
@@ -219,6 +226,10 @@ def remove_input(self, inp: NodeInput):
219226 self .update_shape ()
220227 self .update ()
221228
229+ def on_node_output_added (self , node , index , out : NodeOutput ):
230+ insert = index if index == len (node .outputs ) - 1 else None
231+ self .add_new_output (out , insert )
232+
222233 def add_new_output (self , out : NodeOutput , insert : int = None ):
223234
224235 # create item
@@ -236,6 +247,9 @@ def add_new_output(self, out: NodeOutput, insert: int = None):
236247 self .update_shape ()
237248 self .update ()
238249
250+ def on_node_output_removed (self , node , index , out : NodeOutput ):
251+ self .remove_output (out )
252+
239253 def remove_output (self , out : NodeOutput ):
240254 item = None
241255 for out_item in self .outputs :
0 commit comments