connect tooltip display with xy coords to plot mouse-over event

This commit is contained in:
2023-01-27 18:50:34 +01:00
parent 4e3d8b9da6
commit aeaabd028f

View File

@ -10,6 +10,18 @@ class MDISubPlotBase(MDISubWindow):
self.pw = pw = pg.PlotWidget()
self.setWidget(pw)
# connect to plot mouse-over event
pw.scene().sigMouseMoved.connect(self.on_hover)
def on_hover(self, event):
coord = self.pw.plotItem.vb.mapSceneToView(event)
x = coord.x()
y = coord.y()
x = round(x, 3)
y = round(y, 3)
self.setToolTip(f"x = {x}\ny = {y}")
class MDISubPlot(MDISubPlotBase):