I write an application that displays random number in real time graph, it run perfectly on windows but when I try it on raspberry pi it alwarys stop updating the graph, but the proses in the python shell is still running generate a rundom number and the program didn't.
Any idea, how to fix it?
the example of my code:
from PyQt4.QtCore import QTime, QTimerimport sysimport timeimport threadingfrom pyqtgraph import ViewBox, PlotWidget#import pyqtgraph as pgfrom pyqtgraph.Qt import QtCore, QtGuiimport numpy as npfrom blupblupshub import BlumBlumShubfrom TimeAxisItem import TimeAxisItemfrom collections import dequeimport random
qtCreatorFile = "mejaGetar2.ui"
Ui_MainWindow,QtBaseClass = uic.loadUiType(qtCreatorFile)
class MyApp(QtGui.QTabWidget,Ui_MainWindow): akselerasi = 0 threads = [] threads2 = [] varGraph1 = object aa = False def __init__(self):
QtGui.QTabWidget.__init__(self) Ui_MainWindow.__init__(self) self.setupUi(self) self.akselerasi.setMinimum(0) self.akselerasi.setMaximum(30) self.akselerasi.setValue(0) self.akselerasi.sliderReleased.connect(self.getThread) self.graph1.setRange(xRange=None, yRange=[-1, 1 ]) self.graph1.setLabel('bottom', 'time', 's') self.graph1.showGrid(x=True, y=True) #self.graph1.setLab('bottom',TimeAxisItem(orientation='bottom')) self.graph1.setMouseEnabled(x=False, y=False) MyApp.varGraph1 = self.graph1
self.l1.setText(str(self.akselerasi.value())) #self.currentChanged.connect(self.forceCloseThread)
def getThread(self): if self.sender() == self.akselerasi: MyApp.akselerasii = int(self.akselerasi.value())
if MyApp.akselerasii > 0: thread1 = DynamicThread("akselerasi") if MyApp.aa == True: print("second") minRange = int(self.akselerasi.value()) * -1 self.graph1.setRange(xRange=None, yRange=[minRange, int(self.akselerasi.value()) ]) thread1.trigrer(MyApp.akselerasii) else: thread1.trigrer(MyApp.akselerasii) MyApp.threads2.append(thread1) minRange = int(self.akselerasi.value()) * -1 self.graph1.setRange(xRange=None, yRange=[minRange, int(self.akselerasi.value()) ]) MyApp.aa = True print("first") thread1.start() else: for t in MyApp.threads2: MyApp.aa = False t.stop() self.graph1.clear()
class DynamicThread(threading.Thread,MyApp): intAkselerasi = 0 ruuun = False
def __init__(self,sub): threading.Thread.__init__(self) self.subject = sub def trigrer(self,num): DynamicThread.intAkselerasi = num def run(self): listData = [] a = 0 count = 0 test = 0 t = QTime() t.start() dataGraph = deque(maxlen=20) x1 = [] y1 = [] print("starting " + self.subject) dynamicGenerator = BlumBlumShub() curve = MyApp.varGraph1.plot(pen=(255,0,0)) while DynamicThread.ruuun == True: if DynamicThread.intAkselerasi > 0: minus = DynamicThread.intAkselerasi *-1 data = random.randint(minus,DynamicThread.intAkselerasi) dataGraph.append({'x': t.elapsed(), 'y': data}) x1 = [item['x'] for item in dataGraph] y1 = [item['y'] for item in dataGraph] curve.setData(x=x1, y=y1) print("test: ",data) print("\n") a = a + 1
time.sleep(0.5) else: DynamicThread.ruuun = False print("stop") break print("stoping " + self.subject) dataGraph = [] x1 = [] y1 = [] def start(self): DynamicThread.ruuun = True super(DynamicThread,self).start()
def stop(self): DynamicThread.ruuun = False
if __name__ == "__main__": app = QtGui.QApplication(sys.argv) window = MyApp() window.show() sys.exit(app.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 pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/292d1a51-6aae-4d2c-b7c9-6228dccf178b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.