Hi Patrick and all, Thanks for the quick answer!
Your modification works, but still it does not answer my doubt: I understood that the function that I pass to "connect" assumes to have as argument the ROI itself, but what you suggest give me back the position of the ROI that I moved... true, however I don't know yet WHICH I moved. Having the print of the position, it simply tells me that ONE of them (but not WHICH of them) has reached that position. Is there a way to give some "attribute" to the ROI, like a name or ID, so that the ROI that I moved can pass me back such identifier? Thanks Salvatore Il giorno martedì 7 dicembre 2021 alle 03:24:53 UTC+1 Patrick ha scritto: > 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/30a02993-60c0-456c-8115-ac4784da6d2fn%40googlegroups.com.
