class Plotter(pg.GraphicsWindow):
def __init__(self, parent=None, **kargs):
pg.GraphicsWindow.__init__(self, **kargs)
self.setParent(parent)
self.plt = self.addPlot(row=1, col=0, title="Plot",
labels={'left': 'Voltage [V]',
'bottom': 'time [s]'})
self.curve = self.plt.plot(pen='b')
self.label_cords = pg.LabelItem(justify="right")
self.addItem(self.label_cords)
self.proxy = pg.SignalProxy(self.plt.scene().sigMouseMoved, rateLimit=60,
slot=self.mouseMoved)
self.plot_timer = pg.QtCore.QTimer()
self.plot_timer.timeout.connect(self.updatePlot)
def startPlot(self):
self.plot_timer.start(1000) # how can I trigger it from main class MyApp, which has all other signals/slots connected ?
def stopPlot(self):
self.plot_timer.stop() # I'd like to stop the trigger the same way (pushing STOP button which is in MyApp class)
def mouseMoved(self, evt):
self.mousePoint = self.plt.vb.mapSceneToView(evt[0])
self.label_cords.setText("<span style='font-size: 8pt; color: white'> x = %0.4f, <span style='color: white'> y = %0.4f</span>"
% (self.mousePoint.x(), self.mousePoint.y()))
def updatePlot(self):
self.curve.clear()
self.curve.setData(dfs.data_dictionary['time'], dfs.data_dictionary['Voltage'])
if __name__ == '__main__':
w = Plotter()
w.show()
QtGui.QApplication.instance().exec_()