Hi all,
I appreciate if someone has an answer to the following issue.
Please consider the following code:
def roi_changed(roi):
Handles=roi.getLocalHandlePositions() # Get list of handles
for h in Handles:
position=h[1]
print(position)
print('try to print X position')
print(position[0])
#-------------------------------------------------------------------
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)
roi=pg.PolyLineROI([[5.0,2], [6.0, 2], [6.0, 5]], pen=(6,9), closed=False)
plot.addItem(roi)
roi.sigRegionChangeFinished.connect(lambda roi: roi_changed(roi))
print('Print Handles position as they are created')
Handles=roi.getLocalHandlePositions() # Get list of handles
for h in Handles: # Print handles position
position=h[1]
print(position)
print('... Then when I move one handle...')
pg.exec()
Initially the code will print the positions of the three handles as
following
Point(5.000000, 2.000000)
Point(6.000000, 2.000000)
Point(6.000000, 5.000000)
but when I move one of the handles, so that the "roi_changed" function is
activated by the event, the handle that I move changes its "nature" and
when I print its position I get:
PyQt5.QtCore.QPointF(6.5, 2.9)
instead of
Point(6.5, 2.9)
the problem is that I want to extract the X position and while the
position=Point(5,2) is subscriptable, so that position[0]=5
I cannot do the same to extract X position from PyQt5.QtCore.QPointF
In fact you will see that my code fails
I hope you can help to find a way to extract X position in all the cases
thanks
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/e44e0745-8a65-40f1-b6bb-953234d097d8n%40googlegroups.com.