Thanks so much for  posting this! I was just wondering today about how to 
do this.


On Wednesday, November 14, 2018 at 7:23:41 AM UTC-5, [email protected] 
wrote:
>
>
> 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] ))           
>      
>
>
> On Thursday, May 23, 2013 at 11:06:45 PM UTC+2, Luke Campagnola wrote:
>>
>>
>>
>> On Thu, May 23, 2013 at 11:54 AM, Guillermo Parada <[email protected]> 
>> wrote:
>>
>>> 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?
>>>
>>
>> You can set this:
>>     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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/cbfbc8f4-2389-4132-8f95-6442ac1c4eb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to