MCPcopy Create free account
hub / github.com/bhowiebkr/PyFlowGraph / undo

Method undo

src/commands/create_group_command.py:97–117  ·  view source on GitHub ↗

Remove the created group.

(self)

Source from the content-addressed store, hash-verified

95 return False
96
97 def undo(self) -> bool:
98 """Remove the created group."""
99 if not self.created_group:
100 return False
101
102 try:
103 # Remove from groups list if it exists
104 if hasattr(self.node_graph, 'groups') and self.created_group in self.node_graph.groups:
105 self.node_graph.groups.remove(self.created_group)
106
107 # Remove from scene if it's still there
108 if self.created_group.scene() == self.node_graph:
109 self.node_graph.removeItem(self.created_group)
110
111 print(f"Undid creation of group '{self.created_group.name}'")
112 self._mark_undone()
113 return True
114
115 except Exception as e:
116 print(f"Failed to undo group creation: {e}")
117 return False
118
119 def redo(self) -> bool:
120 """Re-execute the group creation."""

Callers 2

test_command_undoMethod · 0.95
test_command_redoMethod · 0.95

Calls 2

removeMethod · 0.80
_mark_undoneMethod · 0.80

Tested by 2

test_command_undoMethod · 0.76
test_command_redoMethod · 0.76