示例#1
0
    def __init__(self):
        QMainWindow.__init__(self)
        #Built-in UI Setup
        self.setupUi(self)
        self.setWindowIcon(QIcon(findResource("Images/SubmitterMain.png")))

        #Setup the UI with my fuctions
        self.setupGlobals()
        self.hookupButtons()
        self.populateReqs()
        self.populateExecs()
        self.populateJobTypes()
        self.setupForms()
    def buildUI(self):
        #Load style sheet
        with open(findResource("styleSheet.css"), "r") as myStyles:
            self.setStyleSheet(myStyles.read())

        #Global colors
        self.onlineColor = QColor(200, 240, 200)
        self.offlineColor = QColor(240, 200, 200)
        self.whiteColor = QColor(255, 255, 255)

        #Connect Buttons
        self.cancelButton.clicked.connect(self.cancelButtonHandler)
        self.okButton.clicked.connect(self.okButtonHandler)
        self.onlineButton.clicked.connect(self.onlineButtonHandler)
        self.offlineButton.clicked.connect(self.offlineButtonHandler)

        #Set properties
        self.scheduleTable.horizontalHeader().setResizeMode(QHeaderView.Fixed)
        self.scheduleTable.verticalHeader().setResizeMode(QHeaderView.Fixed)

        #Make items in scheduleTable
        rowCount = self.scheduleTable.rowCount()
        colCount = self.scheduleTable.columnCount()
        for i in range(0, rowCount):
            for j in range(0, colCount):
                self.scheduleTable.setItem(i, j, QTableWidgetItem())
                if not self.defaultSchedule:
                    self.scheduleTable.item(i, j).setBackgroundColor(self.onlineColor)
                    self.scheduleTable.item(i, j).setText("1")

        if self.defaultSchedule:
            schedList = []
            for i in range(0, len(self.defaultSchedule)):
                startRow = int(self.defaultSchedule[i].split(":")[0])
                startCol = int(self.defaultSchedule[i].split(":")[1])
                action = int(self.defaultSchedule[i].split(":")[2])
                try:
                    endRow = int(self.defaultSchedule[i + 1].split(":")[0])
                    endCol = int(self.defaultSchedule[i + 1].split(":")[1])
                except IndexError:
                    endRow = 6
                    endCol = 48
                if endRow > startRow:
                    for j in range(startRow, endRow):
                        schedList += [action for _ in range(0, (48 - startCol))]
                        startCol = 0
                schedList += [action for _ in range(startCol, endCol)]

            row = 0
            col = 0
            for item in schedList:
                if item == 1:
                    self.scheduleTable.item(row, col).setBackgroundColor(self.onlineColor)
                    self.scheduleTable.item(row, col).setText("1")
                else:
                    self.scheduleTable.item(row, col).setBackgroundColor(self.offlineColor)
                    self.scheduleTable.item(row, col).setText("0")
                col += 1
                if col > 47:
                    col = 0
                    row += 1
                if row > 6:
                    break