Hi there. I know this question has been asked many times and a possible solution is using a timer (QTimer), but in my case it doesn't work. What I'm doing wrong?
I've also tried to increase the timer step (self.timer.start(200)) and move the processing part of the code to a new "worker" thread, communicating by signals with the UI thread.
Here's a simple version of my code:
from PyQt4 import QtGui, QtCore
import multiprocessing, Queue, time, pyqtgraph, sys
#Main window
import Plotter
def Input(queue):
t = time.clock()
queue.put(t)
def Output(queue, v):
v = queue.get()
# -----------------------------------------------------------------
class UI_Thread(QtGui.QMainWindow, Plotter.Ui_MainWindow):
Start_Worker = QtCore.pyqtSignal()
def __init__(self):
super(self.__class__, self).__init__()
self.setupUi(self)
self.QOn.clicked.connect(self.Calc)
self.q = Queue.Queue(0) #FIFO Constructor
self.v = 0
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.Update)
def Update(self):
p1 = multiprocessing.Process(target=Input, args=(self.q,))
p1.start()
p1.join()
p2 = multiprocessing.Process(target=Output, args=(self.q, self.v))
p2.start()
p2.join()
self.Texto.setText(str(self.v))
def Calc(self):
self.timer.start(200)
# -----------------------------------------------------------------
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
PID = UI_Thread()
PID.show()
app.exec_()