@@ -301,12 +301,13 @@ def add_checkbox(self, name, label='', text='', state=False, tooltip=None,
301301 #: redraw node to address calls outside the "__init__" func.
302302 self .view .draw_node ()
303303
304- def hide_widget (self , name ):
304+ def hide_widget (self , name , push_undo = True ):
305305 """
306306 Hide an embedded node widget.
307307
308308 Args:
309309 name (str): node property name for the widget.
310+ push_undo (bool): register the command to the undo stack. (default: True)
310311
311312 See Also:
312313 :meth:`BaseNode.add_custom_widget`,
@@ -316,14 +317,18 @@ def hide_widget(self, name):
316317 if not self .view .has_widget (name ):
317318 return
318319 undo_cmd = NodeWidgetVisibleCmd (self , name , visible = False )
319- self .graph .undo_stack ().push (undo_cmd )
320+ if push_undo :
321+ self .graph .undo_stack ().push (undo_cmd )
322+ else :
323+ undo_cmd .redo ()
320324
321- def show_widget (self , name ):
325+ def show_widget (self , name , push_undo = True ):
322326 """
323327 Show an embedded node widget.
324328
325329 Args:
326330 name (str): node property name for the widget.
331+ push_undo (bool): register the command to the undo stack. (default: True)
327332
328333 See Also:
329334 :meth:`BaseNode.add_custom_widget`,
@@ -333,7 +338,10 @@ def show_widget(self, name):
333338 if not self .view .has_widget (name ):
334339 return
335340 undo_cmd = NodeWidgetVisibleCmd (self , name , visible = True )
336- self .graph .undo_stack ().push (undo_cmd )
341+ if push_undo :
342+ self .graph .undo_stack ().push (undo_cmd )
343+ else :
344+ undo_cmd .redo ()
337345
338346 def add_input (self , name = 'input' , multi_input = False , display_name = True ,
339347 color = None , locked = False , painter_func = None ):
0 commit comments