123456789101112131415161718192021222324 |
- """
- 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):
- QGraphicsLineItem.__init__(self)
- self._from_item = from_item
- self._to_item = to_item
- 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
|