Hello,
First of all thanks for creating PyQtGraph.I have been working pretty hard
before daring asking here. I am TRYING to make an app where I want to have
several PlotWidgets that plot the signal from up to 5 sensors I've got in
my Arduino. As soon as I have two updating plots, the GUI does not respond,
and I need to pause/restart the plotting, and popping up alerts for some
values. To solve that, I have started researching in order to use QThread,
but that might be impossible with PyQtGraph, since we cannot have plotting
done in multiple threads? My code looks like:
from PyQt4 import QtCore, QtGui
import pyqtgraph as pg
import random
import sys
class MainWindow(QtGui.QWidget):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
layout = QtGui.QHBoxLayout()
self.button = QtGui.QPushButton('Start Plotting Left')
layout.addWidget(self.button)
self.button.clicked.connect(self.plotter)
self.button2 = QtGui.QPushButton('Start Plotting Right')
layout.addWidget(self.button2)
self.button2.clicked.connect(self.plotter2)
self.plot = pg.PlotWidget()
layout.addWidget(self.plot)
self.plot2 = pg.PlotWidget()
layout.addWidget(self.plot2)
self.setLayout(layout)
def plotter(self):
self.data =[0]
self.curve = self.plot.getPlotItem().plot()
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.updater)
self.timer.start(0)
def updater(self):
self.data.append(self.data[-1]+0.2*(0.5-random.random()) )
self.curve.setData(self.data)#Downsampling does not help
def plotter2(self):
self.data2 =[0]
self.curve2 = self.plot2.getPlotItem().plot()
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.updater2)
self.timer.start(0)
def updater2(self):
self.data2.append(self.data[-1]+0.2*(0.5-random.random()) )
self.curve2.setData(self.data) #Downsampling does not help
if __name__ == '__main__':
app = QtGui.QApplication([])
window = MainWindow()
window.show()
app.exec_()
I am ready to read and try everything about QThread, but first I need to know
if it's possible, or if I am wasting my life and sleep.
Should I give up my hopes of achieving a responsive GUI by using the
plot().setdata() method? And perhaps just doing the data appending in a worker
thread and redrawing the plots everytime?
Is there any technology that can do plotting in different threads?
Any help or suggestion am I going to work hard on! :-)
Cheers from the island of Mallorca
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/8beba13d-5d6e-4eab-ba14-b331c0183ea4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.