""" Edge representation for Qt: Same as a LineItem, but stores items it is connected to """ from PyQt5.QtWidgets import QGraphicsItem, QGraphicsLineItem class GraphicsEdgeItem(QGraphicsLineItem): def __init__(self, from_item, to_item, edge_id=None): QGraphicsLineItem.__init__(self) self.from_item = from_item self.to_item = to_item self.edge_id = edge_id self.setFlag(QGraphicsItem.ItemIsMovable, False) self.setFlag(QGraphicsItem.ItemIsSelectable, False) def redraw(self): from_pos = self.from_item.scenePos() to_pos = self.to_item.scenePos() self.setLine(from_pos.x(), from_pos.y(), to_pos.x(), to_pos.y()) # hack to work around failing isinstance check due to import chaos def __hack__(self): return None