Discussion:
[pyqtgraph] How to use Imageview to display only an image and ROI points
b***@gmail.com
2018-11-14 12:23:41 UTC
Permalink
class LabelledROI(ROI):
"""
Normal ROI with a label attached.


==============
=============================================================
**Arguments**
label String for the label
\**args All extra keyword arguments are passed to ROI()
==============
=============================================================

"""
def __init__(self, *args, label=None, **kwargs):
ROI.__init__(self, *args, **kwargs)
if label is not None:
self.label = QtGui.QGraphicsTextItem(label, self)
self.label.setPos(QtCore.QPointF(
self.boundingRect().center().x() - (self.label.boundingRect().width()/2),
self.state['size'][1] ))
else:
self.label = None


def paint(self, p, opt, widget):
""" p es un objeto QPainter """
super().paint(p, opt, widget)
if self.label is not None:
self.label.setPos(QtCore.QPointF(
self.boundingRect().center().x() - (self.label.boundingRect().width()/2),
self.state['size'][1] ))
There is any ROI related feature to add a visible label to a ROI?
There is not, but you can always make a TextItem as a child of the ROI to
achieve this effect.
How can i set the movable property to False after i created the ROI?
roi.translatable = False
But note that this only affects dragging the ROI itself; handles will be
unaffected.
Luke
--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/7aa65c06-6138-489f-9016-92ff60a95b4a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...