Hi Quinty, the thread, as you are using it, will not do anything. In your run() method you're using "thread1" as a statement, which is valid, but doesn't do anything. If you want to call code from your module you have to pack it into a function an then call "thread1.your_function_name()". (Have a look at: https://docs.python.org/2/tutorial/modules.html )
And if you want to use the signal "newData" just to call your "update()" function, you have define it with the same types of parameters (in your case without any): newData = pg.QtCore.Signal() To trigger the signal call "self.newData.emit()" in the run() function of your thread class. (I suggest this tutorial: http://pythoncentral.io/pysidepyqt-tutorial-creating-your-own-signals-and-slots/ ) Cheers, Sebastian Am Donnerstag, 1. Juni 2017 12:34:42 UTC+2 schrieb Quinty van Dijk: > > Hi, > > I'm trying to plot data from a drone in an updating scrolling plot. For > the plotting I use the example code number 3 from this file: > > https://github.com/pyqtgraph/pyqtgraph/blob/develop/examples/scrollingPlots.py > > Now i want to be able to send commands to the drone while the plots keep > updating, because that's the data that I want to see. > Now I figured I need to multi thread using Qt, and got my code form here: > https://groups.google.com/forum/#!topic/pyqtgraph/haiJsGhxTaQ > > But when I start the thread the main thread sleeps. I'm new to this and > have no idea what's happening, can someone help me? > Without the the threading the plots work just fine. > > This is my code: > > import pyqtgraph as pg > import time > from pyqtgraph.Qt import QtCore, QtGui > import numpy as np > from pyardrone import ARDrone, at > import thread1 > > ## Code for plot, copied form example. > -- > > > ## Threading and updating part > > def update(): > print("update") > update_plot_vx() > update_plot_vy() > update_plot_vz() > > > class Thread(pg.QtCore.QThread): > newData = pg.QtCore.Signal(object) > def run(self): > thread1 > > timer = pg.QtCore.QTimer() > timer.timeout.connect(update) > timer.start(50) > > thread = Thread() > thread.newData.connect(update) #It might be something with row, but > removing it doesn't change anything > thread.start() > > # Start Qt event loop unless running in interactive mode or using pyside. > if __name__ == '__main__': > import sys > if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): > QtGui.QApplication.instance().exec_() > > > -- 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/dceced11-68f6-4e32-ade2-86e6aee8743f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
