Skip to content
Snippets Groups Projects
Commit 0caeb405 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Improve PyQCustomPlot example.

parent 911e1cbf
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ class Plot (QtGui.QWidget): ...@@ -24,6 +24,7 @@ class Plot (QtGui.QWidget):
self.qcp.setInteraction(2, True) # iRangeZoom self.qcp.setInteraction(2, True) # iRangeZoom
self.qcp.setAutoAddPlottableToLegend(True) self.qcp.setAutoAddPlottableToLegend(True)
self.qcp.legend().setVisible(True) self.qcp.legend().setVisible(True)
self.qcp.connect (Qt.SIGNAL("mouseDoubleClick(QMouseEvent*)"), self.doubleClick)
# The timer user refresh the interface # The timer user refresh the interface
self.timer = Qt.QTimer(self) self.timer = Qt.QTimer(self)
...@@ -31,6 +32,11 @@ class Plot (QtGui.QWidget): ...@@ -31,6 +32,11 @@ class Plot (QtGui.QWidget):
self.timer.setInterval(100) self.timer.setInterval(100)
self.timer.connect(Qt.SIGNAL("timeout()"), self._step) 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): def makeCurves(self):
self.qcp.clearGraphs() self.qcp.clearGraphs()
self.legends = [ "sin", "cos" ] self.legends = [ "sin", "cos" ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment