Hi,

I'm pretty sure when the signals are emitted, they also pass a reference to 
the ROI which triggered the signal. It's not clear from the documentation, 
but can see it in the underlying code for the ROI 
(https://pyqtgraph.readthedocs.io/en/latest/_modules/pyqtgraph/graphicsItems/ROI.html#ROI.stateChanged).
 
So try changing the connect() line to something like:

roi.sigRegionChangeFinished.connect(lambda r: print(r.pos()))

and see if that works.

Patrick
On Tuesday, 7 December 2021 at 5:47:06 am UTC+10:30 [email protected] wrote:

> Hi all,
>
> I am a beginner, so I hope not to post too trivial question, but I am 
> trying to understand how to do the following: assume I have defined two 
> ROIs and I set the event to print "Hi" when I finish to move a ROI.
> I am able to print "Hi" when I move ANY of the two ROIs, but how can 
> recognize WHICH ROI I moved? Like printing "Hi I moved ROI N. 1" or "Hi I 
> moved ROI N. 2" ?
>
> Here a simple code to explain better my question:
>
> import pyqtgraph as pg
>
> app = pg.mkQApp("Examples")
> win = pg.GraphicsLayoutWidget(show=True, size=(800,800), border=True)
> win.setWindowTitle('ROI Example')
>
> plot = win.addPlot()
> plot.setXRange(0,10)
> plot.setYRange(0,10)
>
> rois=[]
> rois.append(pg.ROI(pos=[3,5],size=[1,1]))
> rois.append(pg.ROI(pos=[7,5],size=[1,1]))
>
> for roi in rois:
>     plot.addItem(roi)
>     roi.sigRegionChangeFinished.connect(lambda: print('Hi'))
>
> pg.exec()
>
> Thanks in advance for any help
> Salvatore
>

-- 
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/db6f1dd2-45a7-472e-9361-1b25ae36e638n%40googlegroups.com.

Reply via email to