I found a solution. The self.view.scene().clickEvents records the mouse press button event and changes when the mouse button is released.
On Wednesday, April 26, 2017 at 11:25:05 AM UTC-4, Daniel Bushey wrote: > > Hi, I am new to pyqtgraph. I am trying to generate rois in an image using > tool that behaves similar to lasso (photoshop) or imfreehand (matlab). So, > I would like to place the mouse cursor on a particular point in the image, > button press, start moving the mouse around a region of interest while > recording x,y coordinates, and then release the mouse closing the selection > process. These coordinates can then be passed to generate an roi. I've been > modifying the class ImageView adding: > self.view.scene().sigMouseMoved2.connect(self.mouseMoved) > self.view.scene().sigMouseClicked.connect(self.mouseClicked) > These two additions allow me to see mouse movements in the def mouseMoved > and initiate roi drawing in def mouseClicked. However, I cannot find a > means to detect when the user releases the mouse button. Ideally, there > would be a signal released when the button is released (ie > self.view.scene().sigMouseReleased.connect(self.mouseRelease) but no such > call exists in the class GraphicsScene. The other means would be detect if > the button is no longer being pressed using the qt event passed into the > mouseMoved definition. Unfortunately, the event being passed is only the > positional data. I've tried modifying the class GraphicsScene def > mouseMoveEvent so all the event data is passed > (self.sigMouseMoved.emit(ev.scenePos()) to self.sigMouseMoved.emit(ev)). > However, the event.button() does not give the correct button (==0) although > from sigMouseClicked the event emitted does give the correct button signal > (event.button() == 1 , which the left mouse button). > > I suppose I could have a mouse click beginning and a second click ending > the roi but this would make the tool work differently than in other > programs causing confusion with some users. > > Any ideas on how to detect whether the mouse button is being pressed or > has been released would be appreciated. Within class GraphicScene, there > are def mouseReleaseEvent and def sendDragEvent but I cannot find an > example using these definitions and don't understand how these definitions > work. > Thank you, > Dan > > -- 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/1b7f2155-78ab-472e-8e63-c4725ab11290%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
