MCPcopy Index your code
hub / github.com/bhowiebkr/PyFlowGraph / Node

Class Node

src/core/node.py:38–778  ·  view source on GitHub ↗

A full-featured, draggable, and resizable block that contains all its functionality in a single class.

Source from the content-addressed store, hash-verified

36
37
38class Node(QGraphicsItem):
39 """
40 A full-featured, draggable, and resizable block that contains all its
41 functionality in a single class.
42 """
43
44 def __init__(self, title, parent=None):
45 super().__init__(parent)
46 self.setFlag(QGraphicsItem.ItemIsMovable)
47 self.setFlag(QGraphicsItem.ItemIsSelectable)
48 self.setFlag(QGraphicsItem.ItemSendsGeometryChanges)
49 self.setAcceptHoverEvents(True)
50
51 # --- Core Attributes ---
52 self.uuid = str(uuid.uuid4())
53 self.title = title
54 self.description = ""
55 self.base_width = 250
56 self.width = self.base_width
57 self.height = 150
58 self.pins, self.input_pins, self.output_pins = [], [], []
59 self.execution_pins, self.data_pins = [], []
60
61 # --- Code Storage ---
62 self.code, self.gui_code, self.gui_get_values_code = "", "", ""
63 self.function_name = None
64 self.gui_widgets = {}
65
66 # --- Interaction State ---
67 self._is_resizing = False
68 self._resize_handle_size = 15
69
70 # --- Visual Properties ---
71 self.color_body = QColor(20, 20, 20, 220)
72 self.color_title_bar = QColor("#2A2A2A")
73 self.color_title_text = QColor("#E0E0E0")
74 self.color_border = QColor(40, 40, 40)
75 self.color_selection_glow = QColor(0, 174, 239, 150)
76 self.pen_default = QPen(self.color_border, 1.5)
77
78 # --- Child Items ---
79 self._title_item = QGraphicsTextItem(self.title, self)
80 self._title_item.setDefaultTextColor(self.color_title_text)
81 self._title_item.setFont(QFont("Arial", 11, QFont.Bold))
82 self._title_item.setPos(10, 5)
83
84 self.proxy_widget = None
85 self._create_content_widget()
86
87 # --- Interaction & Event Handling ---
88
89 def itemChange(self, change, value):
90 if change == QGraphicsItem.ItemSelectedChange:
91 self.highlight_connections(value)
92 if change == QGraphicsItem.ItemPositionHasChanged:
93 for pin in self.pins:
94 pin.update_connections()
95

Callers 15

executeMethod · 0.90
undoMethod · 0.90
create_test_nodeMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90

Calls

no outgoing calls

Tested by 15

create_test_nodeMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
test_delete_node_undoMethod · 0.72