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


Python Qt.DisplayRole方法代码示例

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


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

示例1: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, index, role=Qt.DisplayRole):
        """Return the item data for index.

        Override QAbstractItemModel::data.

        Args:
            index: The QModelIndex to get item flags for.

        Return: The item data, or None on an invalid index.
        """
        if role != Qt.DisplayRole:
            return None
        cat = self._cat_from_idx(index)
        if cat:
            # category header
            if index.column() == 0:
                return self._categories[index.row()].name
            return None
        # item
        cat = self._cat_from_idx(index.parent())
        if not cat:
            return None
        idx = cat.index(index.row(), index.column())
        return cat.data(idx) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:26,代码来源:completionmodel.py

示例2: headerData

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def headerData(self, section, orientation, role=Qt.DisplayRole):
                '''The data for the given role and section in the header with
                the specified orientation.

                Args:
                    section (:obj:`int`):
                    orientation (:obj:`Qt.Orientation`):
                    role (:obj:`Qt.DisplayRole`):

                Returns:
                    data
                '''
                if role != Qt.DisplayRole:
                    return None

                if (orientation == Qt.Horizontal) and (section < len(self.header)):
                    return self.header[section]

                return None 
开发者ID:vrtadmin,项目名称:FIRST-plugin-ida,代码行数:21,代码来源:first.py

示例3: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, index, role = Qt.DisplayRole):
        if not index.isValid():
            return None
        obj = self.getObject(index)
        prop = self.getProperty(index)
        if role == Qt.BackgroundRole:
            return color(obj.D)
        if role == Qt.TextAlignmentRole:
            return Qt.AlignCenter
        if (obj is None) or (prop is None):
            return None
        try:
            if role in [Qt.DisplayRole, Qt.EditRole]:
                return getAttrRecursive(obj, prop['attr'])
        except:
            return None
        return None 
开发者ID:aseylys,项目名称:KStock,代码行数:19,代码来源:ObjList.py

示例4: createEditor

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def createEditor(self, parent, option, index):
        '''
        Return QComboBox with list of choices (either values or their associated keys if they exist).
        '''
        try:
            editor = QComboBox(parent)
            value = index.model().data(index, Qt.DisplayRole)
            for i, choice in enumerate(self.choices):
                if (type(choice) is tuple) and (len(choice) == 2):
                    # choice is a (key, value) tuple.
                    key, val = choice
                    editor.addItem(str(key))  # key MUST be representable as a str.
                    if val == value:
                        editor.setCurrentIndex(i)
                else:
                    # choice is a value.
                    editor.addItem(str(choice))  # choice MUST be representable as a str.
                    if choice == value:
                        editor.setCurrentIndex(i)
            return editor
        except:
            return None 
开发者ID:aseylys,项目名称:KStock,代码行数:24,代码来源:ComboBoxDelegateQt.py

示例5: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, index, role=None):
        if index.isValid():
            data = index.internalPointer()
            col = index.column()
            if data:
                if role in (Qt.DisplayRole, Qt.EditRole):
                    if col == 0:
                        # if isinstance(data, Bip44AccountType):
                        #     return data.get_account_name()
                        # else:
                        #     return f'/{data.address_index}: {data.address}'
                        return data
                    elif col == 1:
                        b = data.balance
                        if b:
                            b = b/1e8
                        return b
                    elif col == 2:
                        b = data.received
                        if b:
                            b = b/1e8
                        return b
        return QVariant() 
开发者ID:Bertrand256,项目名称:dash-masternode-tool,代码行数:25,代码来源:wallet_data_models.py

示例6: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, index, role):
        """ Returns the tree item at the given index and role
        """
        if not index.isValid():
            return None

        col = index.column()
        tree_item = index.internalPointer()
        obj = tree_item.obj

        if role == Qt.DisplayRole:
            try:
                attr = self._attr_cols[col].data_fn(tree_item)
                # Replace carriage returns and line feeds with unicode glyphs 
                # so that all table rows fit on one line. 
                #return attr.replace('', unichr(0x240A)).replace('\r', unichr(0x240D))
                return (attr.replace('\r', unichr(0x21B5))
                        .replace('', unichr(0x21B5))
                        .replace('\r', unichr(0x21B5)))
            except StandardError, ex:
                #logger.exception(ex)
                return "**ERROR**: {}".format(ex) 
开发者ID:dragondjf,项目名称:QMusic,代码行数:24,代码来源:treemodel.py

示例7: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, index, role):
        if not index.isValid():
            return None

        item = index.internalPointer()

        if role == Qt.ForegroundRole:
            if item.itemData[1] == 'removed':
                return QVariant(QColor(Qt.red))
            elif item.itemData[1] == 'added':
                return QVariant(QColor(Qt.green))
            elif item.itemData[1] == 'modified' or item.itemData[1].startswith('['):
                return QVariant(QColor(Qt.darkYellow))

        if role == Qt.DisplayRole:
            return item.data(index.column())
        else:
            return None 
开发者ID:borgbase,项目名称:vorta,代码行数:20,代码来源:diff_result.py

示例8: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, index, role):
        if not index.isValid():
            return None
        node = index.internalPointer()
        if role == Qt.DisplayRole:
            if index.column() == 0:
                return node.name
            elif index.column() == 1:
                return node.capacity
            elif index.column() == 2:
                return node.recoil
            elif index.column() == 3:
                return node.reload
        elif role == Qt.FontRole:
            if index.column() in (1, 2, 3):
                return self.column_font
        return None 
开发者ID:fre-sch,项目名称:mhw_armor_edit,代码行数:19,代码来源:shell_table_editor.py

示例9: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, qindex:QModelIndex, role=None):
        if role == Qt.DisplayRole or role == Qt.EditRole:
            entry = self.entries[qindex.row()]
            attr = self.columns[qindex.column()]
            value = getattr(entry, attr)
            if attr in ("gmd_name_index", "gmd_description_index"):
                return get_t9n(self.model, "t9n", value)
            elif attr == "kire_id":
                kire_model = self.model.get_relation_data("kire")
                if kire_model is None:
                    return None
                else:
                    return kire_model.entries[value]
            return value
        elif role == Qt.UserRole:
            entry = self.entries[qindex.row()]
            return entry 
开发者ID:fre-sch,项目名称:mhw_armor_edit,代码行数:19,代码来源:weapon_editor.py

示例10: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, index, role):
        """ Returns the tree item at the given index and role
        """
        if not index.isValid():
            return None

        col = index.column()
        tree_item = index.internalPointer()
        obj = tree_item.obj

        if role == Qt.DisplayRole:
            try:
                attr = self._attr_cols[col].data_fn(tree_item)
                # Replace carriage returns and line feeds with unicode glyphs 
                # so that all table rows fit on one line. 
                #return attr.replace('\n', unichr(0x240A)).replace('\r', unichr(0x240D))
                return (attr.replace('\r\n', unichr(0x21B5))
                            .replace('\n', unichr(0x21B5))
                            .replace('\r', unichr(0x21B5)))
            except StandardError, ex:
                #logger.exception(ex)
                return "**ERROR**: {}".format(ex) 
开发者ID:dragondjf,项目名称:PFramer,代码行数:24,代码来源:treemodel.py

示例11: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, index, role):
        if not index.isValid():
            return None
        if (index.column() == 0):
            value = self.mylist[index.row()][index.column()].text()
        else:
            value = self.mylist[index.row()][index.column()]
        if role == QtCore.Qt.EditRole:
            return value
            itemSelected.emit()
        elif role == QtCore.Qt.DisplayRole:
            return value
            itemSelected.emit()
        elif role == QtCore.Qt.CheckStateRole:
            if index.column() == 0:
                # print(">>> data() row,col = %d, %d" % (index.row(), index.column()))
                if self.mylist[index.row()][index.column()].isChecked():
                    return QtCore.Qt.Checked
                else:
                    return QtCore.Qt.Unchecked 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:22,代码来源:labelTable.py

示例12: editCell

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def editCell(self,r,c):
        if c==0:
            nameDialog = NameDialog(self.table.item(r,c))
            name = nameDialog.popUp()
            nameItem = QTableWidgetItem(name)
            self.table.setItem(r,0,nameItem)
            colorItem = QTableWidgetItem()
            colorItem.setData(Qt.DisplayRole, QColor('blue'))
            self.table.setItem(r,1,colorItem)
            if r < len(self.labelHist):
                self.labelHist[r]=name
            else:
                self.labelHist.append(name)
            with open('configGUI/predefined_classes.txt', 'w') as f:
                for item in self.labelHist:
                    f.write("%s\n" % item.text()) 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:18,代码来源:predefined_label.py

示例13: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, index, role):
        root = self.get_root_object()
        if role == Qt.DisplayRole or role == Qt.EditRole:
            r = index.row()
            c = index.column()
            eval_str = ('root' + self.colEvalStr[c]).format(r)
            try:
                val = eval(eval_str)
                valStr = self.colFormats[c].format(val)
                return valStr
            except IndexError:
                return ''
            except TypeError:
                print('Data type error: ', eval_str, val)
                return ''
        else:
            return None 
开发者ID:mjhoptics,项目名称:ray-optics,代码行数:19,代码来源:pytablemodel.py

示例14: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, index, role):
        if index.isValid() or (0 <= index.row() < len(self.ListItemData)):
            if role == Qt.DisplayRole:
                return QVariant(self.ListItemData[index.row()]['name'])
            elif role == Qt.DecorationRole:
                return QVariant(QIcon(self.ListItemData[index.row()]['iconPath']))
            elif role == Qt.SizeHintRole:
                return QVariant(QSize(70,80))
            elif role == Qt.TextAlignmentRole:
                return QVariant(int(Qt.AlignHCenter|Qt.AlignVCenter))
            elif role == Qt.FontRole:
                font = QFont()
                font.setPixelSize(20)
                return QVariant(font)
        else:            
            return QVariant() 
开发者ID:Python3Spiders,项目名称:WeiboSuperSpider,代码行数:18,代码来源:ListModel.py

示例15: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import DisplayRole [as 别名]
def data(self, index, role=Qt.DisplayRole):
                '''The data stored under the given role for the item referred
                to by the index.

                Args:
                    index (:obj:`QtCore.QModelIndex`): Index
                    role (:obj:`Qt.ItemDataRole`): Default :obj:`Qt.DisplayRole`

                Returns:
                    data
                '''
                if role == Qt.DisplayRole:
                    row = self._data[index.row()]
                    if (index.column() == 0) and (type(row) != dict):
                        return row

                    elif index.column() < self.columnCount():
                        if type(row) == dict:
                            if self.header[index.column()] in row:
                                return row[self.header[index.column()]]
                            elif self.header[index.column()].lower() in row:
                                return row[self.header[index.column()].lower()]

                        return row[index.column()]

                    return None

                elif role == Qt.FontRole:
                    return QtGui.QFont().setPointSize(30)

                elif role == Qt.DecorationRole and index.column() == 0:
                    return None

                elif role == Qt.TextAlignmentRole:
                    return Qt.AlignLeft; 
开发者ID:vrtadmin,项目名称:FIRST-plugin-ida,代码行数:37,代码来源:first.py


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