排除pyqt应用程序的致命io错误

时间:2019-03-03 04:25:10

标签: python-2.7 pyqt4 raspbian

我有一个pythonpyqt的应用程序。因此,基本上有2个窗口。一个是主窗口,第二个窗口我只需要打开一段时间。问题是我的应用程序可以正常工作一段时间,然后随机fatal io error: client killed崩溃。该错误有时是在应用程序运行后的15分钟内随机出现的,有时是在大约1小时后。以下是我的代码的一部分。

#Main Windows
class UIWindow(QWidget):
def __init__(self, parent=None):
    super(UIWindow, self).__init__(parent)

    headerFont = settings.headerFont
    bigFont = settings.bigFont
    smallFont = settings.smallFont
    movingMessageFont = settings.movingMessageFont

    mainWinlayout = QtGui.QVBoxLayout() #QFormLayout()
    mainWinlayout.setMargin(0)

    H1layout = QtGui.QHBoxLayout()
    H1layout.setMargin(0)

    H2layout = QtGui.QHBoxLayout()
    H2layout.setMargin(0)

    H3layout = QtGui.QHBoxLayout()
    H3layout.setMargin(0)

    H4layout = QtGui.QHBoxLayout()
    H4layout.setMargin(0)

    G1layout = QGridLayout()

    palette0 = QtGui.QPalette()
    palette0.setColor(QtGui.QPalette.WindowText, QtGui.QColor(0, 0, 0, 255))

    palette1 = QtGui.QPalette()
    palette1.setColor(QtGui.QPalette.WindowText, QtGui.QColor(0, 0, 255, 255))

    palette2 = QtGui.QPalette()
    palette2.setColor(QtGui.QPalette.WindowText, QtGui.QColor(0, 128, 0, 255))

    palette3 = QtGui.QPalette()
    palette3.setColor(QtGui.QPalette.WindowText, QtGui.QColor(255, 0, 0, 255))

    self.logo1 = QtGui.QLabel("", self)
    self.logo1.setPixmap(QtGui.QPixmap(settings.logo1))
    self.logo1.setAlignment(QtCore.Qt.AlignRight)


    self.logo2 = QtGui.QLabel("", self)
    self.logo2.setPixmap(QtGui.QPixmap(settings.logo2))

    self.lineName = QtGui.QLabel("HUB G&A L-3", self)
    self.lineName.setStyleSheet(headerFont)
    self.lineName.setAlignment(QtCore.Qt.AlignCenter)
    self.lineName.setWordWrap(True)
    self.lineName.setPalette(palette0)
    #self.lineName.addSpacing(20)

    self.modelName = QtGui.QLabel('MODEL NO. 1', self)
    self.modelName.setStyleSheet(bigFont)
    self.modelName.setAlignment(QtCore.Qt.AlignCenter)
    self.modelName.setWordWrap(True)
    self.modelName.setPalette(palette1)

    self.target = QtGui.QLabel('TARGET', self)
    self.target.setStyleSheet(bigFont)
    self.target.setAlignment(QtCore.Qt.AlignCenter)
    self.target.setWordWrap(True)
    self.target.setPalette(palette2)

    self.plan = QtGui.QLabel('PLAN   ', self)
    self.plan.setStyleSheet(bigFont)
    self.plan.setAlignment(QtCore.Qt.AlignCenter)
    self.plan.setWordWrap(True)
    self.plan.setPalette(palette2)

    self.actual = QtGui.QLabel('ACTUAL', self)
    self.actual.setStyleSheet(bigFont)
    self.actual.setAlignment(QtCore.Qt.AlignCenter)
    self.actual.setWordWrap(True)
    self.actual.setPalette(palette2)

    self.bekido = QtGui.QLabel('BEKIDO', self)
    self.bekido.setStyleSheet(bigFont)
    self.bekido.setAlignment(QtCore.Qt.AlignCenter)
    self.bekido.setWordWrap(True)
    self.bekido.setPalette(palette2)

    self.targetVal = QtGui.QLabel('2000', self)
    self.targetVal.setStyleSheet(bigFont)
    self.targetVal.setAlignment(QtCore.Qt.AlignLeft)
    self.targetVal.setWordWrap(True)
    self.targetVal.setPalette(palette1)

    self.planVal = QtGui.QLabel('0', self)
    self.planVal.setStyleSheet(bigFont)
    self.planVal.setAlignment(QtCore.Qt.AlignLeft)
    self.planVal.setWordWrap(True)
    self.planVal.setPalette(palette1)

    self.actualVal = QtGui.QLabel('0', self)
    self.actualVal.setStyleSheet(bigFont)
    self.actualVal.setAlignment(QtCore.Qt.AlignLeft)
    self.actualVal.setWordWrap(True)
    self.actualVal.setPalette(palette1)

    self.bekidoVal = QtGui.QLabel('0.0 %', self)
    self.bekidoVal.setStyleSheet(bigFont)
    self.bekidoVal.setAlignment(QtCore.Qt.AlignLeft)
    self.bekidoVal.setWordWrap(True)
    self.bekidoVal.setPalette(palette1)

    self.mainMsgLabel = QtGui.QLabel(settings.defaultMessage, self)
    self.mainMsgLabel.setStyleSheet(movingMessageFont)
    self.mainMsgLabel.setAlignment(QtCore.Qt.AlignCenter)
    self.mainMsgLabel.setPalette(palette1)

    self.timeVal = QtGui.QLabel('Current Date & Time', self)
    self.timeVal.setStyleSheet(smallFont)
    self.timeVal.setPalette(palette1)

    self.tacTime = QtGui.QLabel('C/T: 7', self)
    self.tacTime.setStyleSheet(smallFont)
    self.tacTime.setPalette(palette1)

    self.shift = QtGui.QLabel('SHIFT: 0', self)
    self.shift.setStyleSheet(smallFont)
    self.shift.setPalette(palette1)

    self.networkStatus = QtGui.QLabel(settings.networkStatusOffLine, self)
    self.networkStatus.setStyleSheet(smallFont)
    self.networkStatus.setPalette(palette3)


    mainWinlayout.addLayout(H1layout)

    H1layout.addWidget(self.logo2)
    H1layout.addWidget(self.lineName)
    H1layout.addWidget(self.logo1)

    #mainWinlayout.addLayout(H2layout)

    mainWinlayout.addWidget(self.modelName)

    mainWinlayout.addLayout(G1layout)

    G1layout.addWidget(self.target, 0,0)
    G1layout.addWidget(self.targetVal, 0,1)
    G1layout.addWidget(self.plan, 1, 0)
    G1layout.addWidget(self.planVal, 1,1)
    G1layout.addWidget(self.actual, 2,0)
    G1layout.addWidget(self.actualVal, 2,1)
    G1layout.addWidget(self.bekido, 3,0)
    G1layout.addWidget(self.bekidoVal, 3,1)

    mainWinlayout.addLayout(H3layout)
    H3layout.addWidget(self.mainMsgLabel)

    mainWinlayout.addLayout(H4layout)
    H4layout.addWidget(self.timeVal)
    H4layout.addWidget(self.tacTime)
    H4layout.addWidget(self.shift)
    H4layout.addWidget(self.networkStatus)

    self.setLayout(mainWinlayout)

#Second Window
class UI40DISAlertWindow(QWidget):
def __init__(self, parent=None):
    super(UI40DISAlertWindow, self).__init__(parent)
    self.setGeometry(0, 0, 1920, 1080)
    self.showMaximized()

    self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
    headerFont = settings.headerFont
    bigFont = settings.bigFont
    smallFont = settings.smallFont
    movingMessageFont = settings.movingMessageFont

    diWinlayout = QtGui.QVBoxLayout() #QFormLayout()
    diWinlayout.setMargin(0)

    H1DIlayout = QtGui.QHBoxLayout()
    H1DIlayout.setMargin(0)

    H2DIlayout = QtGui.QHBoxLayout()
    H2DIlayout.setMargin(0)

    palette0 = QtGui.QPalette()
    palette0.setColor(QtGui.QPalette.WindowText, QtGui.QColor(0, 0, 0, 255))

    palette1 = QtGui.QPalette()
    palette1.setColor(QtGui.QPalette.WindowText, QtGui.QColor(0, 0, 255, 255))

    palette2 = QtGui.QPalette()
    palette2.setColor(QtGui.QPalette.WindowText, QtGui.QColor(0, 128, 0, 255))

    palette3 = QtGui.QPalette()
    palette3.setColor(QtGui.QPalette.WindowText, QtGui.QColor(255, 0, 0, 255))

    self.setLayout(diWinlayout)

def paintEvent(self, event):
    QWidget.paintEvent(self, event)
    painter = QPainter(self)
    pen = QtGui.QPen(QtCore.Qt.black, 3, QtCore.Qt.SolidLine)

    painter.setPen(pen)

    painter.drawLine(0, 100, 1920, 100)   #50
    painter.drawLine(0, 440, 1920, 440) #150
    painter.drawLine(0, 520, 1920, 520) #350

    painter.drawLine(0, 620, 1920, 620) #400
    painter.drawLine(0, 980, 1920, 980) #650

    tx = 0 #50
    for x in range(12):
        tx = tx + 154
        painter.drawLine(tx, 100, tx, 520)

    tx = 0 #50
    for x in range(25):
        tx = tx + 77
        if x == 8 or x == 16:
            painter.drawLine(tx, 520, tx, 1080)
        elif x == 24:
            painter.drawLine(tx, 0, tx, 1080)
        else:
            painter.drawLine(tx, 620, tx, 1080)

    painter.setBrush(QtGui.QColor(250, 186, 143))
    painter.drawRect(QRect(0, 0, 1920, 100))
    painter.setFont(QtGui.QFont('Consolas', 40, QtGui.QFont.Bold))
    painter.setPen(QtGui.QColor(0, 0, 0))
    painter.drawText(QRect(0, 0, 1920, 100), QtCore.Qt.AlignCenter, 'ASSEMBLY LINE')

    painter.setBrush(QtGui.QColor(225, 153, 204))
    painter.drawRect(QRect(0, 520, 693, 100))

    painter.setBrush(QtGui.QColor(0, 255, 255))
    painter.drawRect(QRect(693, 520, 616, 100))

    painter.setBrush(QtGui.QColor(225, 153, 204))
    painter.drawRect(QRect(1309, 520, 684, 100))

    painter.setFont(QtGui.QFont('Consolas', 40, QtGui.QFont.Bold))
    painter.setPen(QtGui.QColor(0, 0, 0))
    painter.drawText(QRect(0, 520, 693, 100), QtCore.Qt.AlignCenter, 'O/R GRND')
    painter.drawText(QRect(693, 520, 616, 100), QtCore.Qt.AlignCenter, 'I/R GRND')
    painter.drawText(QRect(1309, 520, 584, 100), QtCore.Qt.AlignCenter, 'I/S GRND')


    painter.setPen(QtGui.QColor(0, 0, 0))
    text2 = ['BALL\nASSY', 'IR\nPRESS', 'CONY\n01', 'CLINCH\nING', 'NOISE\nCHECK', 'SEAL B\nPRESS', 'TOTAL\nCHECK', 'CONY\n02', 'ABS\nPRESS', 'MMP\nCHECK', 'RPO', 'VISUAL\nSTAND']

    self._rectBoxLine_color     = QtCore.Qt.black
    self._rectBox_color_R       = QtGui.QColor(200, 0, 0)
    self._rectBox_color_Y       = QtGui.QColor(200, 200, 0)
    self._rectBox_color_G       = QtGui.QColor(0, 200, 0)

    for x in range(12):
        if settings.tempLowMat[x] == 1:
            painter.setBrush(self._rectBox_color_G)
        elif settings.tempLowMat[x] == 2:
            painter.setBrush(self._rectBox_color_Y)
        elif settings.tempLowMat[x] == 4:
            painter.setBrush(self._rectBox_color_R)

            painter.setFont(QtGui.QFont('Consolas', 30, QtGui.QFont.Bold))
            tempVar = [settings.tempCombList.index(item) for item in settings.tempCombList if item[1] == settings.lowerMatrix[x]]
            if tempVar:
                painter.drawText(QRect(154*x, 440, 154, 80), QtCore.Qt.AlignCenter, str(settings.finalPri[tempVar[0]]))
    painter.drawRect(QRect(154*x, 100, 154, 340))

    painter.setFont(QtGui.QFont('Consolas', 40, QtGui.QFont.Bold))

    painter.save()
    tempText = text2[0].split('\n')
    painter.translate(50,340)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.translate(0,80)
    painter.drawText(0,0, tempText[1])  
    painter.restore()

    painter.save()
    tempText = text2[1].split('\n')
    painter.translate(204,320)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.translate(-30,80)
    painter.drawText(0,0, tempText[1])
    painter.restore()

    painter.save()
    tempText = text2[2].split('\n')
    painter.translate(358, 340)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.translate(30,80)
    painter.drawText(0,0, tempText[1])
    painter.restore()

    painter.save()
    tempText = text2[3].split('\n')
    painter.translate(50+154*3, 370)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.translate(50,80)
    painter.drawText(0,0, tempText[1])
    painter.restore()

    painter.save()
    tempText = text2[4].split('\n')
    painter.translate(50+154*4, 340)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.translate(0,80)
    painter.drawText(0,0, tempText[1])
    painter.restore()

    painter.save()
    tempText = text2[5].split('\n')
    painter.translate(50+154*5, 340)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.translate(0,80)
    painter.drawText(0,0, tempText[1])
    painter.restore()

    painter.save()
    tempText = text2[6].split('\n')
    painter.translate(50+154*6, 340)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.translate(0,80)
    painter.drawText(0,0, tempText[1])
    painter.restore()

    painter.save()
    tempText = text2[7].split('\n')
    painter.translate(50+154*7, 340)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.translate(30,80)
    painter.drawText(0,0, tempText[1])
    painter.restore()

    painter.save()
    tempText = text2[8].split('\n')
    painter.translate(50+154*8, 340)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.translate(-30,80)
    painter.drawText(0,0, tempText[1])
    painter.restore()

    painter.save()
    tempText = text2[9].split('\n')
    painter.translate(50+154*9, 340)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.translate(-30,80)
    painter.drawText(0,0, tempText[1])
    painter.restore()

    painter.save()
    tempText = text2[10].split('\n')
    painter.translate(77+154*10, 340)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.restore()

    painter.save()
    tempText = text2[11].split('\n')
    painter.translate(50+154*11, 340)
    painter.rotate(-90)
    painter.drawText(0,0, tempText[0])

    painter.translate(0,80)
    painter.drawText(0,0, tempText[1])
    painter.restore()


    painter.setPen(QtGui.QColor(0, 0, 0))
    text1 = ['INPUT.', 'VG 300', 'VG 100 R', 'VG100 F', 'DEMAG', 'SF FLG', 'SF BOSS', 'W&M', 'BUFFER.', 'HOPPER', 'KVD',
            '3RG 450', 'GIA', 'BORE CHKR', 'I/R S/F', 'IR WASH.', 'OH CON.', 'INPUT.', 'VG 300 A', 'DEMAG', 'I/S SF',
            'W&M', 'BUFFER', 'BOLT P.', 'OH CON.']


    for x in range(25):
        if settings.tempUpMat[x] == 1:
            painter.setBrush(self._rectBox_color_G)
        elif settings.tempUpMat[x] == 2:
            painter.setBrush(self._rectBox_color_Y)
        elif settings.tempUpMat[x] == 4:
            painter.setBrush(self._rectBox_color_R)

            painter.setFont(QtGui.QFont('Consolas', 30, QtGui.QFont.Bold))
            tempVar = [settings.tempCombList.index(item) for item in settings.tempCombList if item[1] == settings.upperMatrix[x]]
            if tempVar:
                painter.drawText(QRect(77*x, 980, 77, 80),      QtCore.Qt.AlignCenter, str(settings.finalPri[tempVar[0]]))
    painter.drawRect(QRect(77*x, 620, 77, 360))


    painter.setFont(QtGui.QFont('Consolas', 40, QtGui.QFont.Bold))

    for x in range(25):
        if x == 13:
            painter.save()
            painter.translate(48 + 77*x, 970)
            painter.rotate(-90)
            painter.drawText(0,0, text1[x])
            painter.restore()
        else:
            painter.save()
            painter.translate(48 + 77*x, 940)
            painter.rotate(-90)
            painter.drawText(0,0, text1[x])
            painter.restore()

    painter.save()
    pen = QtGui.QPen(QtCore.Qt.black, 8, QtCore.Qt.SolidLine)
    painter.setPen(pen)
    painter.drawLine(693,522,693,1080)
    painter.drawLine(1309,522,1309,1080)
    painter.restore()

如何调试此错误?

0 个答案:

没有答案