20 lines
698 B
Python
20 lines
698 B
Python
"""Port definitions for node editor."""
|
|
|
|
|
|
class Port:
|
|
"""Represents an input or output port on a node."""
|
|
|
|
def __init__(self, name: str, port_type: str, label: str = ""):
|
|
self.name = name # e.g. "in", "out", "out_0", "out_1"
|
|
self.port_type = port_type # "input" or "output"
|
|
self.label = label or name
|
|
self.canvas_id = None
|
|
self.x = 0
|
|
self.y = 0
|
|
# "L" or "R" — set by NodeWidget during draw based on the node's
|
|
# flipped state. Wire routing uses it to pick curve control points.
|
|
self.side = "L" if port_type == "input" else "R"
|
|
|
|
def __repr__(self):
|
|
return f"Port({self.name}, {self.port_type})"
|