PDA

View Full Version : [PyQwt] Drawing a curve with QwtPlotPicker



banshee.beats
8th August 2013, 14:18
Hello everyone,

i'm trying to let the user draw a curve on my plot canvas, to emit a signal after releasing the mouse and send the array of points to another method for further processing.

Right now my code looks like this:



(...)
self.plotPicker = Qwt.QwtPlotPicker(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.PolygonSelection, Qwt.QwtPlotPicker.PolygonRubberBand, Qwt.QwtPicker.AlwaysOn, plot.canvas())
self.plotPicker.setRubberBandPen(QPen(Qt.green))
self.plotPicker.setTrackerPen(QPen(Qt.cyan))
self.connect(self.plotPicker, SIGNAL('selected(const QwtArrayQwtDoublePoint &)'), self.onSelection)


def onSelection(self, points):
print 'i got triggered'


This does not work, the method does not get triggered. If i replace QwtPicker.PolygonSelection with QwtPicker.PointSelection and change the SIGNAL accordingly it works just fine.

Where am i going wrong here? Thanks a lot in advance!