Hi,

This looks like it should work, until you see your "__init()" method should 
be "__init__()"!

Patrick

On Friday, 1 May 2020 05:23:08 UTC+9:30, Wahabo Ouedraogo wrote:
>
> Hi everyone!
> I created a class Plot_Curve_Item that herite of the PlotCurveItem class 
> of pyqtgraph. In the manufacturer of the class, I declare a timer which is 
> a QTimeLine instance of Qt. I redefine the HoverEvent method to increase 
> the thickness of the curve when the mouse flies over it for a time of 
> 1000ms. so I call the start function of QTimerLine to start the timer. I 
> connect the finished signal of the timer to the Timer slot that I defined 
> in the class Plot_Curve_Item to draw the width of the curve to 2 once the 
> time of 1000 ms is elapsed. However, when I execute the code, python sends 
> me this message:
>
>  Error sending hover exit event:
>
>     *|==============================>>*
> *    |  Traceback (most recent call last):*
> *    |    File "d:/Documents/VISUAL STUDIO CODE EXO/PlotCurve.py", line 
> 39, in <module>*
> *    |      sys.exit(app.exec_())*
> *    |    File 
> "C:\Users\ThinkPad\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyqtgraph\widgets\GraphicsView.py",
>  
> line 368, in mouseMoveEvent*
> *    |      QtGui.QGraphicsView.mouseMoveEvent(self, ev)*
> *    |    File 
> "C:\Users\ThinkPad\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyqtgraph\GraphicsScene\GraphicsScene.py",
>  
> line 162, in mouseMoveEvent*
> *    |      self.sendHoverEvents(ev)*
> *    |    File 
> "C:\Users\ThinkPad\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyqtgraph\GraphicsScene\GraphicsScene.py",
>  
> line 256, in sendHoverEvents*
> *    |      debug.printExc("Error sending hover exit event:")*
> *    |    --- exception caught here ---*
> *    |    File 
> "C:\Users\ThinkPad\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyqtgraph\GraphicsScene\GraphicsScene.py",
>  
> line 254, in sendHoverEvents*
> *    |      item.hoverEvent(event)*
> *    |    File "d:/Documents/VISUAL STUDIO CODE EXO/PlotCurve.py", line 
> 20, in hoverEvent*
> *    |      self.timer.start()*
> *    |  AttributeError: 'Plot_Curve_Item' object has no attribute 'timer'*
> *    |==============================<<*
>
> *Here's the whole code:*
>
>
>
> from PyQt5.QtCore import *
> from PyQt5.QtGui import *
> from PyQt5.QtWidgets import *
> import pyqtgraph as pg
> from pyqtgraph.Qt import QtGui, QtCore
> import numpy as np
> import time
> import sys
>
>
> class Plot_Curve_Item(pg.PlotCurveItem):
>     def __init(self,parent = None):
>         super().__init__(parent=parent)
>         self.setParent(parent)
>         self.timer = QTimeLine(1000)
>         self.timer.finished.connect(self.Timer)
>
>     def hoverEvent(self,event):
>         self.timer.start()
>         self.setPen(width=4)
>     
>     def Timer(self):
>         self.setPen(width=2)
>
>
> if __name__ == "__main__":
>     app = QApplication(sys.argv)
>     widget = QMainWindow()
>     x1 = np.linspace(0,20,10)
>     y1 =  np.arange(0,10)
>     Plot_Widget = pg.PlotWidget()
>     Plot_Item = pg.PlotItem()
>     plot_item_curve = Plot_Curve_Item(x1,y1)
>     Plot_Item.addItem(plot_item_curve)
>     Plot_Widget.addItem(Plot_Item)
>     widget.setCentralWidget(Plot_Widget)
>     widget.show()
>     sys.exit(app.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/367c1701-7e38-4011-bcb4-0d58a57d72bc%40googlegroups.com.

Reply via email to