diff options
author | Blaine | 2020-06-16 20:51:22 +0530 |
---|---|---|
committer | Blaine | 2020-06-16 20:51:22 +0530 |
commit | 88e0706a2e359806d5787bdb21bcdaf4e105f9ae (patch) | |
tree | 1d05d19105e95d8519512b68c61dbb380f38a470 /src/main/python/shapes/line.py | |
parent | d7ae38811d4830c6a93c76630c475e8a5b222ece (diff) | |
download | Chemical-PFD-88e0706a2e359806d5787bdb21bcdaf4e105f9ae.tar.gz Chemical-PFD-88e0706a2e359806d5787bdb21bcdaf4e105f9ae.tar.bz2 Chemical-PFD-88e0706a2e359806d5787bdb21bcdaf4e105f9ae.zip |
values as properties and reverse name change event
Diffstat (limited to 'src/main/python/shapes/line.py')
-rw-r--r-- | src/main/python/shapes/line.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index bbeab30..66be069 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -1,8 +1,9 @@ import math from PyQt5.QtGui import QPen, QPainterPath, QBrush, QPainterPathStroker, QPainter, QCursor, QPolygonF from PyQt5.QtWidgets import QGraphicsItem, QGraphicsPathItem, QGraphicsTextItem, QMenu, QGraphicsLineItem -from PyQt5.QtCore import Qt, QPointF, QRectF, QLineF +from PyQt5.QtCore import Qt, QPointF, QRectF, QLineF, pyqtSignal +from collections import defaultdict class Grabber(QGraphicsPathItem): """ @@ -122,6 +123,8 @@ class Grabber(QGraphicsPathItem): class LineLabel(QGraphicsTextItem): + nameChanged = pyqtSignal() + def __init__(self, pos, parent=None): super(LineLabel, self).__init__() self.setPlainText("abc") @@ -139,7 +142,8 @@ class LineLabel(QGraphicsTextItem): self.line.setPen(QPen(Qt.black, 2, Qt.SolidLine)) self.line.setFlag(QGraphicsItem.ItemStacksBehindParent) self.resetPos() - + self.values = defaultdict(lambda: 0) + def paint(self, painter, option, widget): painter.save() painter.setPen(QPen(Qt.black, 2, Qt.SolidLine)) @@ -264,6 +268,7 @@ class LineLabel(QGraphicsTextItem): def focusOutEvent(self, event): super(LineLabel, self).focusOutEvent(event) self.setTextInteractionFlags(Qt.NoTextInteraction) + self.nameChanged.emit() def __getstate__(self): return { |