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


Python QTableWidgetItem.setForeground方法代码示例

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


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

示例1: coloredTableWidgetItem

# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setForeground [as 别名]
 def coloredTableWidgetItem(self, text, color, userData=None):
     item = QTableWidgetItem(text)
     item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
     item.setForeground(color)
     if userData:
         item.setData(Qt.UserRole, userData)
     return item
开发者ID:elricbk,项目名称:pyenvelopes,代码行数:9,代码来源:MainForm.py

示例2: __init__

# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setForeground [as 别名]
    def __init__(self, updates, streetdb):
        QDialog.__init__(self)
        self.setupUi(self)
        table = self.tableWidget
        table.setRowCount(len(updates)+1)
        table.setColumnCount(len(common.ATT))
        self.setWindowTitle("Overview")

        for i in range(len(common.ATT)):
            item = QTableWidgetItem(common.ATT_HR[common.ATT[i]])
            table.setItem(0, i, item)
        for i, street in enumerate(updates):
            changes = updates[street]
            row = []
            for z in range(len(common.ATT)):
                found = False
                att = common.ATT[z]
                print(att)
                for change in changes:
                    split = change.split(":")
                    if split[0] == att:
                        row.append(split[1])
                        found = True
                if not found:
                    try:
                        row.append(streetdb[street][att])
                    except KeyError:
                        """print("Error building diagram in Street:", street, " Attribute: ", att) ## Missing field"""
            for x, update in enumerate(row):
                item = QTableWidgetItem(update)
                if "->" in update:
                    item.setForeground(Qt.red)
                print(i+1, x, update)
                table.setItem(i+1, x, item)
        self.load_settings()
开发者ID:nylser,项目名称:P-Seminar-Util,代码行数:37,代码来源:table2dbf_gui.py

示例3: __init__

# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setForeground [as 别名]
    def __init__(self, messages, hiddenLifelines, parent = None):
        super(HiddenMessageDialog, self).__init__(parent)

        self.lifelineList = hiddenLifelines
        self.msgList = messages
        layout = QVBoxLayout(self)

        listTitle = QLabel('Hidden Messages')
        layout.addWidget(listTitle)

        self.listHiddenMessages = QtGui.QTableWidget(len(self.msgList),4)
        self.listHiddenMessages.setHorizontalHeaderLabels(['Index','Name','Departure','Destination'])
        self.listHiddenMessages.setFixedWidth(400)
        #self.listHiddenMessages.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)
        self.listHiddenMessages.setSelectionBehavior(QAbstractItemView.SelectRows)

        for idx, msg in enumerate(self.msgList):
            self.listHiddenMessages.setItem(idx,0,QTableWidgetItem("%d" % msg['messageindex']))
            self.listHiddenMessages.setItem(idx,1,QTableWidgetItem(msg['message']))
            item = QTableWidgetItem(msg['departure']['class'])
            item.setTextAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
            if msg['departure']['class'] in self.lifelineList:
                item.setForeground(QColor(200,200,200)) 
            self.listHiddenMessages.setItem(idx,2,item)

            item = QTableWidgetItem(msg['dest'])
            item.setTextAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
            if msg['dest'] in self.lifelineList:
                item.setForeground(QColor(200,200,200)) 
            self.listHiddenMessages.setItem(idx,3,item)

        layout.addWidget(self.listHiddenMessages)

        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self)
        buttons.button(QDialogButtonBox.Ok).setText('Show')
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons)
开发者ID:OpenDanbi,项目名称:Sherlock,代码行数:40,代码来源:HiddenMessageDialog.py


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