当前位置: 首页>>代码示例>>Python>>正文


Python QStandardItem.setBackground方法代码示例

本文整理汇总了Python中PyQt5.QtGui.QStandardItem.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.setBackground方法的具体用法?Python QStandardItem.setBackground怎么用?Python QStandardItem.setBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtGui.QStandardItem的用法示例。


在下文中一共展示了QStandardItem.setBackground方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addFiles

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setBackground [as 别名]
 def addFiles(self, files):
     itemCount = 0
     imageFiles = []
     self.model = QStandardItemModel()
     for file in files:
         if self.__isImage(file):
             imageFiles.append(file)
             item = QStandardItem(file)
             if itemCount % 2 == 0:
                 item.setBackground(QBrush(QColor(221, 222, 211)))
             self.model.appendRow(QStandardItem(item))
             itemCount += 1
     if itemCount == 0:
         QMessageBox.information(None, "No Image Files!",
                         "指定ディレクトリには画像がありません。")
     self.setModel(self.model)
     return imageFiles
开发者ID:ligerbolt,项目名称:image-augmentator,代码行数:19,代码来源:mywidgets.py

示例2: colorize

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setBackground [as 别名]
    def colorize(self, excelModel, prologModel):

        for row in range(prologModel.rowCount()):

            if str(excelModel.data(excelModel.index(row, 0))).lower() == "none":
                if "_lab" in str(prologModel.data(prologModel.index(row, 1))).lower() or "lab_" in str(prologModel.data(prologModel.index(row, 2))).lower():
                    pass
                else:
                    for column in range(prologModel.columnCount()):
                        if str(prologModel.data(prologModel.index(row, column))).lower() != str(excelModel.data(excelModel.index(row, column))).lower():
                            toAdd = QStandardItem(str(prologModel.data(prologModel.index(row, column))))
                            toAdd.setBackground(QBrush(QColor(255, 155, 55, 200)))
                            prologModel.setItem(row, column, toAdd)


            elif str(prologModel.data(prologModel.index(row, 2))).lower() not in str(excelModel.data(excelModel.index(row, 1))).lower(): #confronto docente
                toAdd = QStandardItem(str(prologModel.data(prologModel.index(row, 2))))
                toAdd.setBackground(QBrush(QColor(255, 0, 0, 100)))
                prologModel.setItem(row, 2, toAdd)

            elif str(excelModel.data(excelModel.index(row, 4))).lower() != str(prologModel.data(prologModel.index(row, 5))).lower(): #confronto ore
                toAdd = QStandardItem(str(prologModel.data(prologModel.index(row, 5))))
                toAdd.setBackground(QBrush(QColor(255, 0, 0, 100)))
                prologModel.setItem(row, 5, toAdd)

            """"
开发者ID:lovalova1991,项目名称:Tesi,代码行数:28,代码来源:ManageUI.py

示例3: createExcelModel

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setBackground [as 别名]
    def createExcelModel(self, excelView):
        listCorsi = Compare.Compare().startCompare()
        listNewCorsi = Compare.Compare().getNewCorsi()
        for element in listNewCorsi:
            listCorsi.append(element)

        #messagebox per controllare i nuovi corsi
        if (len(listNewCorsi) > 0):
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Information)
            msg.resize(400, 400)
            msg.setText("Attenzione")
            msg.setInformativeText("Sono stati aggiunti dei corsi!")
            msg.setWindowTitle("Attenzione")
            toPrint = ""
            for element in listNewCorsi:
                toPrint = str(toPrint) + "*" + str(element.nomecorso) + "\n"
            msg.setDetailedText(toPrint)
            msg.exec_()

        try:
            self.tableModel = QStandardItemModel()
            self.tableModel.setHorizontalHeaderItem(0, QStandardItem("Nome Corso"))
            self.tableModel.setHorizontalHeaderItem(1, QStandardItem("Docente"))
            self.tableModel.setHorizontalHeaderItem(2, QStandardItem("Seguito Da"))
            self.tableModel.setHorizontalHeaderItem(3, QStandardItem("Anno"))
            self.tableModel.setHorizontalHeaderItem(4, QStandardItem("Numero Ore"))
        except AttributeError:
            print("uops")

        excelView.setModel(self.tableModel)

        for row in range(0, len(listCorsi)):

            nomecorso = QStandardItem(str(listCorsi[row].nomecorso))
            docente = QStandardItem(str(listCorsi[row].docente))
            seguitoda = QStandardItem(str(listCorsi[row].seguitoda))
            anno = QStandardItem(str(listCorsi[row].anno))
            numore = QStandardItem(str(listCorsi[row].numore))
            docenteHint = QStandardItem(str(listCorsi[row].docenteHint))
            numoreHint = QStandardItem(str(listCorsi[row].numOreHint))

            self.tableModel.insertRow(row)

            #se sono corsi nuovi li evidenzio in verde
            if listCorsi[row].docente == "" and listCorsi[row].numore == "":
                nomecorso.setBackground(QBrush(QColor(0,255,85,200)))
                docente.setBackground(QBrush(QColor(0, 255, 85, 200)))
                seguitoda.setBackground(QBrush(QColor(0, 255, 85, 200)))
                numore.setBackground(QBrush(QColor(0, 255, 85, 200)))
                anno.setBackground(QBrush(QColor(0, 255, 85, 200)))
                docenteHint.setBackground(QBrush(QColor(0, 255, 85, 200)))
                numoreHint.setBackground(QBrush(QColor(0, 255, 85, 200)))

            self.tableModel.setItem(row, 0, nomecorso)
            if (str(listCorsi[row].docente)) == str(None) or str(listCorsi[row].docente) == "":
                docenteHint.setBackground(QBrush(QColor(255,0,0,100)))
                self.tableModel.setItem(row, 1, docenteHint)
            else:
                self.tableModel.setItem(row, 1, docente)

            self.tableModel.setItem(row, 2, seguitoda)
            self.tableModel.setItem(row, 3, anno)

            if (listCorsi[row].numore == None):
                numoreHint.setBackground(QBrush(QColor(255,0,0,100)))
                self.tableModel.setItem(row, 4, numoreHint)
            else:
                self.tableModel.setItem(row, 4, numore)

        excelView.resizeColumnsToContents()
        return self.tableModel
开发者ID:lovalova1991,项目名称:Tesi,代码行数:74,代码来源:Model.py

示例4: createPrologModel

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setBackground [as 别名]
    def createPrologModel(self, prologView):
        listProlog = Prolog.getPrologList()
        for element in listProlog:
            if str(element.fullname).startswith("[pre"):
                listProlog.remove(element)

        self.prologModel = QStandardItemModel()
        self.prologModel.modelReset

        self.prologModel.setHorizontalHeaderItem(0, QStandardItem("Nome Corso"))
        self.prologModel.setHorizontalHeaderItem(1, QStandardItem("Nome Schematico"))
        self.prologModel.setHorizontalHeaderItem(2, QStandardItem("Docente"))
        self.prologModel.setHorizontalHeaderItem(3, QStandardItem("Numero Studenti"))
        self.prologModel.setHorizontalHeaderItem(4, QStandardItem("Corso / Anno"))
        self.prologModel.setHorizontalHeaderItem(5, QStandardItem("Numero Ore"))
        self.prologModel.setHorizontalHeaderItem(6, QStandardItem("Laboratorio"))
        self.prologModel.setHorizontalHeaderItem(7, QStandardItem("Numero Slot"))
        self.prologModel.setHorizontalHeaderItem(8, QStandardItem("Durata Slot"))
        self.prologModel.setHorizontalHeaderItem(9, QStandardItem("Tipo"))
        self.prologModel.setHorizontalHeaderItem(10, QStandardItem("Link"))
        self.prologModel.setHorizontalHeaderItem(11, QStandardItem("Commento"))

        for row in range(0, len(listProlog)):
            listCorsi =  str(listProlog[row].seguitoda).replace("][", "],[")
            nomecorso = QStandardItem(str(listProlog[row].fullname))
            shortName = QStandardItem(str(listProlog[row].nomecorso))
            docente = QStandardItem(str(listProlog[row].docente))
            numstudenti = QStandardItem(str(listProlog[row].numstudenti))
            seguitoda = QStandardItem(str(listCorsi))
            numore = QStandardItem(str(listProlog[row].numore))
            lab = QStandardItem(str(listProlog[row].lab))
            numslot = QStandardItem(str(listProlog[row].numslot))
            if str(listProlog[row].slotdur) != "None":
                slotdur = QStandardItem(str(listProlog[row].slotdur))
            else:
                slotdur = QStandardItem("_")
            type = QStandardItem(str(listProlog[row].type))
            link = QStandardItem(str(listProlog[row].link))

            prologView.setModel(self.prologModel)

            self.prologModel.insertRow(row)

            #imposto il background dei laboratori
            if listProlog[row].fullname == "[]" or "_lab" in str(listProlog[row].nomecorso) or "lab_" in str(listProlog[row].nomecorso):
                nomecorso.setBackground(QBrush(QColor(65, 205, 255, 200)))
                shortName.setBackground(QBrush(QColor(65, 205, 255, 200)))
                docente.setBackground(QBrush(QColor(65, 205, 255, 200)))
                numstudenti.setBackground(QBrush(QColor(65, 205, 255, 200)))
                seguitoda.setBackground(QBrush(QColor(65, 205, 255, 200)))
                numore.setBackground(QBrush(QColor(65, 205, 255, 200)))
                lab.setBackground(QBrush(QColor(65, 205, 255, 200)))
                numslot.setBackground(QBrush(QColor(65, 205, 255, 200)))
                slotdur.setBackground(QBrush(QColor(65, 205, 255, 200)))
                type.setBackground(QBrush(QColor(65, 205, 255, 200)))
                link.setBackground(QBrush(QColor(65, 205, 255, 200)))

            self.prologModel.setItem(row, 0, nomecorso)
            self.prologModel.setItem(row, 1, shortName)
            self.prologModel.setItem(row, 2, docente)
            self.prologModel.setItem(row, 3, numstudenti)
            self.prologModel.setItem(row, 4, seguitoda)
            self.prologModel.setItem(row, 5, numore)
            self.prologModel.setItem(row, 6, lab)
            self.prologModel.setItem(row, 7, numslot)
            self.prologModel.setItem(row, 8, slotdur)
            self.prologModel.setItem(row, 9, type)
            self.prologModel.setItem(row, 10, link)
            self.prologModel.setItem(row, 11, QStandardItem("Inserisci Commento..."))

            prologView.resizeColumnsToContents()

        return self.prologModel
开发者ID:lovalova1991,项目名称:Tesi,代码行数:75,代码来源:Model.py


注:本文中的PyQt5.QtGui.QStandardItem.setBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。