connect tooltip display with xy coords to plot mouse-over event
This commit is contained in:
@ -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):
|
||||
|
Reference in New Issue
Block a user