问题描述
我从串行端口接收实时数据,当单击“开始”按钮时,必须先读取数据。我可以正确接收数据,但GUI冻结,然后无法将它们绘制到合并到QgraphicView中的pyqtgraph中。那么我将有两个问题:
- 我应该怎么做,才能使我的GUI不冻结?
- 如何将实时数据绘制到合并的pyqtgraph中? 我在下面的主要代码(请注意,GUI代码是由QtDesigner制作的,这已包含在其他代码中): (如果您能帮助我将pyqtgraph与QgraphicView合并,我非常感谢学习)
tempf = []
shc = []
ser = serial.Serial('COM13',9600)
class SetUI_main(Ui_Form):
def __init__(self):
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.draw)
def draw(self):
time.sleep(0.5)
sh = 0
while True:
time.sleep(0.1)
data = ser.readline()
temp = float(data.decode())
sh += 0.6
shc.append(sh)
tempf.append(temp)
print(tempf)
#print(shc)
self.graphicsView.plot(tempf,shc)
def start(self):
s = 's'.encode('ascii')
ser.write(s)
print('Start')
self.timer.start(2000)
def connector(self):
self.pushButton_13.clicked.connect(self.start)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)