How can I acquire data from live experimentation and do a live 2D plot using threads? <p>I need to take data from an instrument and live 2D plot them. I can do it without threads, but it is slow ... How could I proceed without having errors like "QObject::setParent: Cannot set parent, new parent is in a different thread", "QApplication: Object event filter cannot be in a different thread" and "QPixmap: It is not safe to use pixmaps outside the GUI thread". I used this code as a test:</p> <pre><code> import threading import time import numpy as np import matplotlib.pyplot as plt class myThread (threading.Thread): def __init__(self, threadID, name, counter): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.counter = counter s=(6,6) self.x=np.zeros(s) def run(self): print "Starting " + self.name threadLock.acquire() if self.threadID==1: acquire_data(self.x) count_to_three(self.name,1) plot_it(self.x) count_to_three(self.name,1) print "Exiting "+ self.name if self.threadID==2: count_to_three(self.name,1) print "Exiting "+ self.name threadLock.release() def print_time(threadName, delay, counter): while counter: time.sleep(delay) print "%s: %s" % (threadName, time.ctime(time.time())) counter -= 1 def count_to_three(threadName,delay): i=0 while i&lt;4: time.sleep(delay) print"%s: %s" % (threadName,i) i+=1 def acquire_data(x): return def plot_it(x): sidex = np.linspace(0,6,6) sidey = np.linspace(0,6,6) X,Y = np.meshgrid(sidex,sidey) plt.subplot(111) plt.pcolormesh(X,Y,x) return # Create new threads plt.figure() threadLock=threading.Lock() while True: threads=[] thread1 = myThread(1, "Thread-1", 3) thread2 = myThread(2, "Thread-2", 2) # Start new Threads thread1.start() thread2.start() # Add threads to thread list threads.append(thread1) threads.append(thread2) for t in threads: plt.show() t.join() </code></pre>