示例#1
0
class MainWindow(QMainWindow):
    focusName = ['-', '-', '-', '-', '-']
    focusTime = ['00:00:00', '00:00:00', '00:00:00', '00:00:00', '00:00:00']
    activeName = ['-', '-', '-', '-', '-']
    activeTime = ['00:00:00', '00:00:00', '00:00:00', '00:00:00', '00:00:00']
    layout = QVBoxLayout()
    fileToRead = 'temp.csv'
    running = True

    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        self.setWindowTitle("Self Spy")
        self.spy = 0
        self.setWindowFlag(Qt.WindowTitleHint)
        self.resize(1000, 900)
        self.setStyleSheet("background-color: #F0DFF7;")

        self.highGroundLayout = QHBoxLayout()

        self.clock = Clock()
        self.focusChart = PieChart()

        self.highGroundLayout.addWidget(self.clock)
        self.highGroundLayout.addWidget(self.focusChart)

        self.focusLayout = Focus(self.focusName, self.focusTime)
        self.activeLayout = Active(self.activeName, self.activeTime)

        self.middleLayout = QHBoxLayout()
        self.middleLayout.addLayout(self.focusLayout)
        self.middleLayout.addLayout(self.activeLayout)

        self.layout.addLayout(self.highGroundLayout)
        self.layout.addLayout(self.middleLayout)

        widget = QWidget()
        widget.setLayout(self.layout)
        self.setCentralWidget(widget)

    def closeEvent(self, event):
        self.running = False

    def initSpy(self):
        self.spy = Spy(self)

    def updateWindow(self, focusName, focusTime, activeName, activeTime,
                     focusPath):
        self.focusLayout.updateName(focusName)
        sleep(0.5)
        self.focusLayout.updateTime(focusTime)
        sleep(0.5)
        self.activeLayout.updateName(activeName)
        sleep(0.5)
        self.activeLayout.updateTime(activeTime)
        sleep(1.25)
        self.focusChart.chartUpdate(focusPath)