Hi all

I am currently trying/struggling with the mouse interaction... I might have 
just passed the correct lines in the documentation but i just can't get it 
to work. What I want to achieve is getting the starting positon (mouse 
button pressed), the moving event (hovering...) and when I am finished 
dragging the mouse (mouse button release).

The following is a very crude MWE... can somebody help?

#!/usr/bin/env python
import sys

from PyQt5.QtWidgets import QApplication, QMainWindow, QToolBar, QAction
import pyqtgraph as pqg


class Builder(QMainWindow):

    def __init__(self, parent=None):
       super(Builder, self).__init__(parent)
       self.setupWidget()
   
   def setupWidget(self):
       self.toolbar = Toolbar(self)
       self.addToolBar(self.toolbar)

        self.win = pqg.GraphicsWindow()
       self.canvas = self.win.addPlot(row=1, col=0)
       self.canvas.showGrid(x=True, y=True)

        self.scene = self.canvas.scene()
       self.scene.sigMouseHover.connect(self.onMouseHover)
       self.scene.sigMouseClicked.connect(self.onMouseClick)
       print(self.scene.parent)
       print(dir(self.scene))
       
       self.setCentralWidget(self.win)

    def onMouseMove(self, events):
       print("MOVE", events)
       pos = events[0]
       x = self.canvas.vb.mapSceneToView(pos).x()
       y = self.canvas.vb.mapSceneToView(pos).y()
       # print(x, y)

    def onMouseClick(self, events):
       print("LENGTH", len(self.scene.clickEvents))
       print("CLICK", events)
       evts = self.scene.clickEvents
       print(evts)
       # for ev in evts:
       #     print(ev.pos())
       #     print(ev.lastPos())

    def onMouseHover(self, events):
       print("LENGTH", len(self.scene.clickEvents))
       print("HOVER", events)
       evts = self.scene.clickEvents
       print(evts)
       # for ev in evts:
       #     print(ev.pos())
       #     print(ev.lastPos())
   


class Toolbar(QToolBar):

    def __init__(self, parent=None):
       """."""
       super(Toolbar, self).__init__(parent)
       self.setupWidget()
   
   def setupWidget(self):
       self.setMovable(True)
       self.setFloatable(True)
       self.rect = QAction("rect", checkable=True)

        self.addAction(self.rect)



if __name__ == '__main__':
   app = QApplication(sys.argv)
   app.setApplicationName("hulk_mad.py")

    main = Builder()
   main.show()

    sys.exit(app.exec_())

:-/ .. I have to confess that I am a biiiiiit frustrated

-- 
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/7e61e7f7-2f9c-4e7f-85b2-82cc62aa0dc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to