Thank you very much, the problem is solved

Le lundi 22 novembre 2021 à 23:34:01 UTC, [email protected] a écrit :

> Hi, sorry I didn't reply earlier, you might have to call Plot_Item.show() 
> first so the scene gets generated/attached.
>
> On Saturday, October 9, 2021 at 6:26:59 AM UTC-7 [email protected] 
> wrote:
>
>> 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/6ffa0b0f-69c3-403d-8d33-4d385c55d4ccn%40googlegroups.com.

Reply via email to