11#!/usr/bin/python
22from collections import OrderedDict
33
4- from NodeGraphQt .base .commands import NodeVisibleCmd
4+ from NodeGraphQt .base .commands import NodeVisibleCmd , NodeWidgetVisibleCmd
55from NodeGraphQt .base .node import NodeObject
66from NodeGraphQt .base .port import Port
77from NodeGraphQt .constants import NodePropWidgetEnum , PortTypeEnum
8- from NodeGraphQt .errors import (PortError ,
9- PortRegistrationError ,
10- NodeWidgetError )
8+ from NodeGraphQt .errors import (
9+ PortError ,
10+ PortRegistrationError ,
11+ NodeWidgetError
12+ )
1113from NodeGraphQt .qgraphics .node_base import NodeItem
12- from NodeGraphQt .widgets .node_widgets import (NodeBaseWidget ,
13- NodeComboBox ,
14- NodeLineEdit ,
15- NodeCheckBox )
14+ from NodeGraphQt .widgets .node_widgets import (
15+ NodeBaseWidget ,
16+ NodeCheckBox ,
17+ NodeComboBox ,
18+ NodeLineEdit
19+ )
1620
1721
1822class BaseNode (NodeObject ):
@@ -290,9 +294,6 @@ def hide_widget(self, name):
290294 """
291295 Hide an embedded node widget.
292296
293- Warnings:
294- Undo is NOT yet supported for this function.
295-
296297 Args:
297298 name (str): node property name for the widget.
298299
@@ -301,20 +302,15 @@ def hide_widget(self, name):
301302 :meth:`BaseNode.show_widget`,
302303 :meth:`BaseNode.get_widget`
303304 """
304- # TODO: implement this logic to the undo stack.
305305 if not self .view .has_widget (name ):
306306 return
307- widget = self .view .get_widget (name )
308- widget .hide ()
309- self .view .draw_node ()
307+ undo_cmd = NodeWidgetVisibleCmd (self , name , visible = False )
308+ self .graph .undo_stack ().push (undo_cmd )
310309
311310 def show_widget (self , name ):
312311 """
313312 Show an embedded node widget.
314313
315- Warnings:
316- Undo is NOT yet supported for this function.
317-
318314 Args:
319315 name (str): node property name for the widget.
320316
@@ -323,12 +319,10 @@ def show_widget(self, name):
323319 :meth:`BaseNode.hide_widget`,
324320 :meth:`BaseNode.get_widget`
325321 """
326- # TODO: implement this logic to the undo stack.
327322 if not self .view .has_widget (name ):
328323 return
329- widget = self .view .get_widget (name )
330- widget .show ()
331- self .view .draw_node ()
324+ undo_cmd = NodeWidgetVisibleCmd (self , name , visible = True )
325+ self .graph .undo_stack ().push (undo_cmd )
332326
333327 def add_input (self , name = 'input' , multi_input = False , display_name = True ,
334328 color = None , locked = False , painter_func = None ):
0 commit comments