From 0caeb405008fa7e1294e23c5c15fcbbf413e3501 Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Fri, 30 Mar 2018 11:36:35 +0200 Subject: [PATCH] Improve PyQCustomPlot example. --- examples/pyplugin/qcustomplot_example.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/pyplugin/qcustomplot_example.py b/examples/pyplugin/qcustomplot_example.py index fb4ca9c..ff412be 100644 --- a/examples/pyplugin/qcustomplot_example.py +++ b/examples/pyplugin/qcustomplot_example.py @@ -24,6 +24,7 @@ class Plot (QtGui.QWidget): self.qcp.setInteraction(2, True) # iRangeZoom self.qcp.setAutoAddPlottableToLegend(True) self.qcp.legend().setVisible(True) + self.qcp.connect (Qt.SIGNAL("mouseDoubleClick(QMouseEvent*)"), self.doubleClick) # The timer user refresh the interface self.timer = Qt.QTimer(self) @@ -31,6 +32,11 @@ class Plot (QtGui.QWidget): self.timer.setInterval(100) self.timer.connect(Qt.SIGNAL("timeout()"), self._step) + def doubleClick (self, event): + x = self.qcp.xAxis().pixelToCoord (event.posF().x()) + y = self.qcp.yAxis().pixelToCoord (event.posF().y()) + print("You double-clicked at ({0}, {1})".format(x, y)) + def makeCurves(self): self.qcp.clearGraphs() self.legends = [ "sin", "cos" ] -- GitLab