I've tried to adapt the crosshair example to my code without success - I
cannot get the mouse clicked event to fire. I think I must be missing
something basic. Here is the code I have tried. I am new to pyqtgraph, so
any suggestions would be gratefully received.
imageViewer = pg.GraphicsLayoutWidget()
imageViewer.setMouseTracking(True)
viewBox = imageViewer.addViewBox()
imageViewer.scene().sigMouseClicked.connect(self.getPixel)
#also tried, without success
#viewBox.proxy = pg.SignalProxy(viewBox.scene().sigMouseClicked,
rateLimit=60, slot=self.getPixel)
def getPixel(self, event):
print('getPixel')
print (str(event.pos().x()),str(event.pos().y()))
event.accept()
On Monday, February 17, 2020 at 3:19:11 PM UTC, Stephen Shillitoe wrote:
>
>
> I have built a PyQt5, Python 3.7 windows application that uses PyQtGraph
> to view monochrome (greyscale) Magnetic Resonance DICOM images. As I move
> the mouse pointer over the image, I would like to display the value of the
> pixel under the pointer on the window. There is no obvious (to me)
> functionality in PyQtGraph to do this. I would be very grateful for any
> suggestions by more experienced developers of how to do this. Here is an
> edited code segment showing how I display the image (pixelArray) in an MDI
> subwindow.
>
> layout = QVBoxLayout()
> widget = QWidget()
> widget.setLayout(layout)
> self.subWindow.setWidget(widget)
>
> imageViewer = pg.GraphicsLayoutWidget()
> viewBox = imageViewer.addViewBox()
> image= pg.ImageItem(border='w')
> viewBox.addItem(image)
> imageView = pg.ImageView(view=viewBox, imageItem=image)
> layout.addWidget(imageView)
> imageView.setImage(pixelArray)
>
>
--
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/0d87bb4c-22d7-40f6-99fd-ebd639a3dacc%40googlegroups.com.