if i run this code i get the following error which i don't understand:
Traceback (most recent call last):
File "d: \ PyQt \ VS Code \ crosshair_example.py", line 45, in <module>
Plot_Item.scene (). SigMouseMoved.connect (mouseMoved)
AttributeError: 'NoneType' object has no attribute 'sigMouseMoved'
PS D: \ PlattFomio Projects \ Arduino Memory Project>
This is the code :
import numpy as np
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore
from pyqtgraph.Point import Point
from pyqtgraph.graphicsItems import PlotItem
import sys
app = pg.mkQApp("Crosshair Example")
data1 = 10000 + 15000 * pg.gaussianFilter(np.random.random(size=100), 10) +
3000 * np.random.random(size=100)
Plot_Item = pg.PlotItem()
label = pg.LabelItem(justify='right')
Plot_Item.addItem(label)
Plot_Item.plot(data1)
vLine = pg.InfiniteLine(angle=90, movable = False)
hLine = pg.InfiniteLine(angle=0, movable= False)
Plot_Item.addItem(vLine, ignoreBounds=True)
Plot_Item.addItem(hLine, ignoreBounds=True)
vb = Plot_Item.vb
def mouseMoved(evt):
pos = evt
if Plot_Item.sceneBoundingRect().contains(pos):
mousePoint = vb.mapSceneToView(pos)
index = int(mousePoint.x())
if index > 0 and index < len(data1):
label.setText("<span style='font-size: 12pt'>x=%0.1f, <span
style='color: red'>y1=%0.1f</span>, <span style='color:
green'>y2=%0.1f</span>" % (mousePoint.x(), data1[index], data2[index]))
vLine.setPos(mousePoint.x())
hLine.setPos(mousePoint.y())
Plot_Item.scene().sigMouseMoved.connect(mouseMoved)
if __name__ == '__main__':
pg.exec()
--
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/4aa2826b-4181-4c62-9727-5e40ca816b73n%40googlegroups.com.