In other words, is there any way to either
1. Make sigClicked somehow give the data of adjacent points or
2. Make sigPointsClicked fire when clicking an adjacent line segment?
3. (Or some alternative I'm not thinking of)
Being new to Google groups posting I thought I could edit my original.
Since I can't find a way, here is some sample code:
import pyqtgraph as pg
import numpy as np
tri = np.array([[0,0], [0,5], [5,5], [0,0]])
nans = np.array([[np.nan, np.nan]])
tris = []
datas = []
for ii in np.arange(0, 16, 5):
tris.append(tri + ii)
tris.append(nans)
datas.extend([ii]*5) # One data for each point
tris = np.vstack(tris)
datas = np.array(datas)
def ptsClicked(item, pts):
print(f'ID {pts[0].data()} Clicked!')
app = pg.mkQApp()
triItem = pg.PlotDataItem(x=tris[:,0], y=tris[:,1], data=datas, symbol='o')
triItem.sigPointsClicked.connect(ptsClicked)
w = pg.PlotWindow()
w.plotItem.addItem(triItem)
w.show()
app.exec()
On Saturday, June 6, 2020 at 9:44:36 PM UTC-4, Nathan Jessurun wrote:
>
> Hi there,
>
> My overall goal is to have several clickable regions overlaid on an image,
> and if the plot boundary of any region is clicked I get a signal with the
> ID of that region. Something like this:
> I tried making each boundary a separate plot data item, but I have 1000s
> of bounds that update frequently so it lagged a ton. So, I just used
> connect='finite' within the same plot item to make it much faster.
>
> However, now I can't give a separate ID to each boundary. I have to make
> the vertices stand out, and connect to sigclicked(...pts) instead:
>
> This works, but I'd love to be able to click anywhere on one of the line
> segments for the same effect. Is there any way to make this happen?
>
> Relevant code is just a PlotDataItem on a plot widget.
>
> Thanks!
>
--
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/fb10aa48-efe9-40f9-ae3e-553c1998d8e0o%40googlegroups.com.