import pyqtgraph as pgp = pg.plot()def printMousePos(pos):global pprint p.plotItem.vb.mapSceneToView(pos)p.scene().sigMouseMoved.connect(printMousePos)
from pyqtgraph.Qt import QtCore, QtGuiclass Crosshair(QtGui.QGraphicsItem):def __init__(self):QtGui.QGraphicsItem.__init__(self)self.setFlag(self.ItemIgnoresTransformations)
def paint(self, p, *args):p.setPen(pg.mkPen('y'))p.drawLine(-10, 0, 10, 0)p.drawLine(0, -10, 0, 10)
def boundingRect(self):return QtCore.QRectF(-10, -10, 20, 20)
import pyqtgraph as pgp = pg.plot()
ch = Crosshair()p.addItem(ch)ch.setPos(0.5, 0.3)
The crosshair I was talking about is tied to mouse events and redraws
a full vertical and horizontal line as you move the mouse. The
intersection of the two lines would be where the mouse is.
I tried
adding a mouse move event handler function to the cross hair object
but it does not seem to be called.
In that case, I would just use two InfiniteLine items. In the same callback that connects to scene.sigMouseMoved, you can set the position of each line.
I tried:w = win.addPlot(row=windowNumber, col=0)def sigMouseMovedHandler(evt):print evtQtCore.QObject.connect(w,QtCore.SIGNAL("sigMouseMoved"),sigMouseMovedHandler)
And that did not seem to work. How would I connect to sigMouseMoved signal?
- The center of the cross hair is not exactly on the mouse (off by around 10-20 pixels for both x and y). I'm guessing that I'm not taking into account the width of the axis labels.
- There is a problem with redraw. If I comment out the region code below, it works fine. However, If I don't comment out the code, there are gaps which show up on the plot as I move the mouse around.
- The y axis scale is set to 0 - 15000, even though the data is from 10000-15000, If I remove the cross hair the y axis scales correctly.
- How would I add the x and y values on the right hand top corner of the graph?
Performance: [not that important]- On larger datasets the cross hair movement is not super smooth, would it make sense to redraw every 100ms or higher from a performance reason? Any other ways to improve performance?
I don't have this problem .. can you send a screenshot? Exactly which lines of code do you comment out to solve the problem?
Shall I credit you in the example? (as 'pyqtgraphuser' ?)
Thanks for the quick turn around on your bug fixes and updates.I don't have this problem .. can you send a screenshot? Exactly which lines of code do you comment out to solve the problem?I've attached a screenshot. If I comment out the following lines I don't see the gaps as I move the mouse around:#region.sigRegionChanged.connect(update)#region.setRegion([1000, 2000])
That is quite strange! Is this screenshot from the example program I posted, unmodified?I'm going to have to ponder that.. If I understand correctly, moving the mouse over the top plot causes these black regions to appear, but mouse over the bottom plot is ok? And if you pan/scale the top plot or move the region, then it redraws correctly?
That is quite strange! Is this screenshot from the example program I posted, unmodified?I'm going to have to ponder that.. If I understand correctly, moving the mouse over the top plot causes these black regions to appear, but mouse over the bottom plot is ok? And if you pan/scale the top plot or move the region, then it redraws correctly?The graph is from the example program unmodified. There is something very wrong at least on my computer.
- operating system? 64/32 bit?
- PyQt / PySide version?
- graphics chipset / driver?
- using opengl compositing window manager (compiz / kwin) ?
- any changes made to your local pyqtgraph library at all?
What's the best way to find this and the installed qt version?
>>> from pyqtgraph.Qt import QtCore>>> QtCore.PYQT_VERSION_STR>>> QtCore.QT_VERSION_STR
$ dpkg -l python-pyside
- graphics chipset / driver?I'll try and figure this out as well. Let me know if you know an easy way to find this out?
$ lspci | grep VGA
- using opengl compositing window manager (compiz / kwin) ?
Can I connect the signal on a viewBox instead of a plot?
I tried both methods from the example code but it raises that viewBox doesn't have the signal... =/
Em sexta-feira, 30 de março de 2012 19h34min18s UTC+1, megan escreveu:
I tried:w = win.addPlot(row=windowNumber, col=0)def sigMouseMovedHandler(evt):print evtQtCore.QObject.connect(w,QtCore.SIGNAL("sigMouseMoved"),sigMouseMovedHandler)And that did not seem to work. How would I connect to sigMouseMoved signal?There are two APIs for connecting signals in PyQt4, an older way and a newer way. You can find documentation about them here:The connection you defined uses the old API. In order to also support using PySide (which only supports the new API) as a backend, pyqtgraph uses the new API. Additionally, while it's possible to use the old API style to connect signals that come with PyQt, signals that are defined within pyqtgraph (like sigMouseMoved) can only be connected using the new API.The syntax for this looks like:w.scene().sigMouseMoved.connect(sigMouseMovedHandler)You need the w.scene() call because sigMouseMoved is an attribute of GraphicsScene, not PlotItem.Hope that's helpful.Cheers,Megan
---- [ You are subscribed to pyqt...@googlegroups.com. To unsubscribe, send email to pyqtgraph+...@googlegroups.com ]---
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 pyqtgraph+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.