PyQTGraph最小化时停止刷新

时间:2018-10-04 09:36:57

标签: python pyqt qt5 pyqtgraph

我正在编写一个工具,该工具实时显示PyQTGraph传入的tcp数据。 在工具中,QT小部件中嵌入了3d和2D PyQTGraph。
很多时候,当我最小化工具或更改Splitter-Size时,2D图形将停止刷新。更新例程仍在工作,因为当我最小化和最大化该工具时,二维图会刷新1次。

这是该工具的屏幕截图,显示了两个由QT拆分器分隔的图形
Tool

这是《守则》的一部分,应该以某种方式负责。

TCP更新例程:

class TCP_Handler:

    def updateGraphs(self):
        # starting independent Graph-Threads
        self.graphfutures = []
        future = self.executor.submit(self.surface3d_Graph.updateData, self.completeFrames.copy())
        self.graphfutures.append(future)
        future = self.executor.submit(self.line2D_Graph.updateData, self.completeFrames.copy())

GUI:

class Ui_MainWindow(object):

    def setupUi(self, MainWindow):
        self.lineGraphWidget = Line2DGraph(defaultNumberOfData, self.splitter)
        self.lineGraphWidget.setObjectName("widget")

PyQTGraph:

class Line2DGraph(pg.GraphicsLayoutWidget):

    def initLines(self):
        for index in self.activeChannels:
            self.linesList[index] = self.p1.plot(self.dataArray[index], pen=(index, 3))


    def updateData(self, framesList):
        try:
            for frame in framesList:
                for activeChannel in self.activeChannels:
                    self.dataArray[activeChannel][:-1] = self.dataArray[activeChannel][
                                                         1:]  # shift data in the array one sample left
                    # (see also: np.roll)
                    self.dataArray[activeChannel][-1] = frame[activeChannel]
                    self.dataArray[activeChannel][
                        np.isinf(self.dataArray[activeChannel])] = np.nan  # should prevent problems with autoscaling
                    self.linesList[activeChannel].setData(self.graphrange, self.dataArray[activeChannel])
        except:
            print("2D Update:", sys.exc_info()[1])

完整代码位于GitHub

0 个答案:

没有答案