From aeaabd028f7f627c4fe06f32330800aa0c30facc Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Fri, 27 Jan 2023 18:50:34 +0100 Subject: [PATCH] connect tooltip display with xy coords to plot mouse-over event --- grum/mdi/mdisubplot.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/grum/mdi/mdisubplot.py b/grum/mdi/mdisubplot.py index 57ca35d..53bc67e 100644 --- a/grum/mdi/mdisubplot.py +++ b/grum/mdi/mdisubplot.py @@ -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):