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

Method execute

src/commands/node/basic_operations.py:63–124  ·  view source on GitHub ↗

Create the node and add to graph.

(self)

Source from the content-addressed store, hash-verified

61 self.created_node = None
62
63 def execute(self) -> bool:
64 """Create the node and add to graph."""
65 try:
66 if self.is_reroute:
67 # Create reroute node
68 self.created_node = self.node_graph.create_node("", pos=(self.position.x(), self.position.y()), is_reroute=True, use_command=False)
69 self.created_node.uuid = self.node_id
70 else:
71 # Import here to avoid circular imports
72 from core.node import Node
73
74 # Create the node
75 self.created_node = Node(self.title)
76 self.created_node.uuid = self.node_id
77 self.created_node.description = self.node_description
78 self.created_node.setPos(self.position)
79
80 # Set code first so pins are generated
81 if self.code:
82 self.created_node.code = self.code
83 self.created_node.update_pins_from_code()
84
85 # Set GUI code
86 if self.gui_code:
87 self.created_node.set_gui_code(self.gui_code)
88 if self.gui_get_values_code:
89 self.created_node.set_gui_get_values_code(self.gui_get_values_code)
90
91 # Apply size - use minimum size calculation for validation
92 if self.size and len(self.size) >= 2:
93 # Get minimum size for this node
94 min_width, min_height = self.created_node.calculate_absolute_minimum_size()
95
96 # Apply size with minimum validation
97 self.created_node.width = max(self.size[0], min_width)
98 self.created_node.height = max(self.size[1], min_height)
99
100 # Apply colors
101 if self.colors:
102 from PySide6.QtGui import QColor
103 if "title" in self.colors:
104 self.created_node.color_title_bar = QColor(self.colors["title"])
105 if "body" in self.colors:
106 self.created_node.color_body = QColor(self.colors["body"])
107
108 # Update visual representation
109 self.created_node.update()
110
111 # Apply GUI state after GUI is created
112 if self.gui_state:
113 self.created_node.apply_gui_state(self.gui_state)
114
115 # Add to graph
116 self.node_graph.addItem(self.created_node)
117 self.node_graph.nodes.append(self.created_node)
118
119 self._mark_executed()
120 return True

Callers 2

test_create_node_undoMethod · 0.95

Calls 8

NodeClass · 0.90
create_nodeMethod · 0.80
update_pins_from_codeMethod · 0.80
set_gui_codeMethod · 0.80
apply_gui_stateMethod · 0.80
_mark_executedMethod · 0.80

Tested by 2

test_create_node_undoMethod · 0.76