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


Python Qt.FontRole方法代码示例

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


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

示例1: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [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

示例2: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [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

示例3: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [as 别名]
def data(self, index: QModelIndex, role=None):
        item = self.getItem(index)
        if role == Qt.DisplayRole:
            return item.data()
        elif role == Qt.DecorationRole and item.is_group:
            return QIcon.fromTheme("folder")
        elif role == Qt.CheckStateRole:
            return item.show
        elif role == Qt.FontRole:
            if item.is_group and self.rootItem.index_of(item) in self.controller.active_group_ids:
                font = QFont()
                font.setBold(True)
                return font
            elif item.protocol in self.controller.selected_protocols:
                font = QFont()
                font.setBold(True)
                return font
        elif role == Qt.ToolTipRole:
            return item.data() 
开发者ID:jopohl,项目名称:urh,代码行数:21,代码来源:ProtocolTreeModel.py

示例4: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [as 别名]
def data(self, index: QModelIndex, role=None):
        i = index.row()
        j = index.column()
        if role == Qt.DisplayRole:
            if self.data is None:
                return None
            else:
                if self.proto_view == 0:
                    return self.data[i][j]
                elif self.proto_view == 1:
                    return "{0:x}".format(int(self.data[i][4 * j:4 * (j + 1)], 2))
                elif self.proto_view == 2:
                    return chr(int(self.data[i][8 * j:8 * (j + 1)], 2))

        elif role == Qt.FontRole:
            if i == 0:
                font = QFont()
                font.setBold(True)
                return font
        elif role == Qt.TextAlignmentRole:
            return Qt.AlignCenter 
开发者ID:jopohl,项目名称:urh,代码行数:23,代码来源:FuzzingTableModel.py

示例5: loadAddressComboBox

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [as 别名]
def loadAddressComboBox(self, mn_list):
        comboBox = self.ui.addressComboBox
        for x in mn_list:
            if x['isHardware']:
                name = x['name']
                address = x['collateral'].get('address')
                hwAcc = x['hwAcc']
                spath = x['collateral'].get('spath')
                hwpath = "%d'/0/%d" % (hwAcc, spath)
                isTestnet = x['isTestnet']
                comboBox.addItem(name, [address, hwpath, isTestnet])
        # add generic address (bold)
        comboBox.addItem("Generic address...", ["", "", False])
        boldFont = QFont("Times")
        boldFont.setBold(True)
        comboBox.setItemData(comboBox.count() - 1, boldFont, Qt.FontRole)
        # init selection
        self.onChangeSelectedAddress() 
开发者ID:PIVX-Project,项目名称:PIVX-SPMT,代码行数:20,代码来源:dlg_signmessage.py

示例6: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [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

示例7: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [as 别名]
def data(self, index: QModelIndex, role=None):
        if role == Qt.FontRole or role == Qt.TextColorRole:
            file_name = self.get_file_path(index)
            if hasattr(self, "open_files") and file_name in self.open_files:
                if role == Qt.FontRole:
                    font = QFont()
                    font.setBold(True)
                    return font
                elif role == Qt.TextColorRole:
                    return QColor("orange")

        return super().data(index, role) 
开发者ID:jopohl,项目名称:urh,代码行数:14,代码来源:FileFilterProxyModel.py

示例8: data

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [as 别名]
def data(self, index: QModelIndex, role=None):
        row = index.row()
        if role == Qt.DisplayRole:
            return self.plugins[row].name
        elif role == Qt.CheckStateRole:
            return self.plugins[row].enabled
        elif role == Qt.TextColorRole and self.plugins[row] in self.highlighted_plugins:
            return settings.HIGHLIGHT_TEXT_FOREGROUND_COLOR
        elif role == Qt.BackgroundColorRole and self.plugins[row] in self.highlighted_plugins:
            return settings.HIGHLIGHT_TEXT_BACKGROUND_COLOR
        elif role == Qt.FontRole and self.plugins[row] in self.highlighted_plugins:
            font = QFont()
            font.setBold(True)
            return font 
开发者ID:jopohl,项目名称:urh,代码行数:16,代码来源:PluginListModel.py

示例9: test_performance

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [as 别名]
def test_performance(self):
        self.cframe = self.form.compare_frame_controller
        self.gframe = self.form.generator_tab_controller
        self.form.ui.tabWidget.setCurrentIndex(2)
        self.cframe.ui.cbProtoView.setCurrentIndex(0)
        self.gframe.ui.cbViewType.setCurrentIndex(0)
        proto = self.__build_protocol()
        self.cframe.add_protocol(proto)
        proto.qt_signals.protocol_updated.emit()
        self.assertEqual(self.cframe.protocol_model.row_count, self.NUM_MESSAGES)
        self.assertEqual(self.cframe.protocol_model.col_count, self.BITS_PER_MESSAGE)
        self.__add_labels()
        item = self.gframe.tree_model.rootItem.children[0].children[0]
        index = self.gframe.tree_model.createIndex(0, 0, item)
        rect = self.gframe.ui.treeProtocols.visualRect(index)
        QTest.mousePress(self.gframe.ui.treeProtocols.viewport(), Qt.LeftButton, pos = rect.center())

        self.assertEqual(self.gframe.ui.treeProtocols.selectedIndexes()[0], index)
        mimedata = self.gframe.tree_model.mimeData(self.gframe.ui.treeProtocols.selectedIndexes())
        t  = time.time()
        self.gframe.table_model.dropMimeData(mimedata, 1, -1, -1, self.gframe.table_model.createIndex(0, 0))
        print("{0}: {1} s".format("Time for dropping mimedata", (time.time() - t)))
        self.assertEqual(self.gframe.table_model.row_count, self.NUM_MESSAGES)

        print("==============================00")
        indx = self.gframe.table_model.createIndex(int(self.NUM_MESSAGES / 2), int(self.BITS_PER_MESSAGE / 2))
        roles = (Qt.DisplayRole, Qt.BackgroundColorRole, Qt.TextAlignmentRole, Qt.TextColorRole, Qt.FontRole)
        time_for_display = 100
        for role in roles:
            t = time.time()
            self.gframe.table_model.data(indx, role = role)
            microseconds = (time.time() - t) * 10 ** 6
            self.assertLessEqual(microseconds, 2 * time_for_display, msg=self.__role_to_str(role))
            if role == Qt.DisplayRole:
                time_for_display = microseconds
            print("{0}: {1} µs".format(self.__role_to_str(role), microseconds)) 
开发者ID:jopohl,项目名称:urh,代码行数:38,代码来源:TestGeneratorTablePerformance.py

示例10: __role_to_str

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [as 别名]
def __role_to_str(self, role):
        if role == Qt.DisplayRole:
            return "Display"
        if role == Qt.BackgroundColorRole:
            return "BG-Color"
        if role == Qt.TextAlignmentRole:
            return "Text-Alignment"
        if role == Qt.TextColorRole:
            return "TextColor"
        if role == Qt.ToolTipRole:
            return "ToolTip"
        if role == Qt.FontRole:
            return "Font" 
开发者ID:jopohl,项目名称:urh,代码行数:15,代码来源:TestGeneratorTablePerformance.py

示例11: updateRPClist

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [as 别名]
def updateRPClist(self):
        # Clear old stuff
        self.updatingRPCbox = True
        self.header.rpcClientsBox.clear()
        public_servers = self.parent.db.getRPCServers(custom=False)
        custom_servers = self.parent.db.getRPCServers(custom=True)
        self.rpcServersList = public_servers + custom_servers
        # Add public servers (italics)
        italicsFont = QFont("Times", italic=True)
        for s in public_servers:
            url = s["protocol"] + "://" + s["host"].split(':')[0]
            self.header.rpcClientsBox.addItem(url, s)
            self.header.rpcClientsBox.setItemData(self.getServerListIndex(s), italicsFont, Qt.FontRole)
        # Add Local Wallet (bold)
        boldFont = QFont("Times")
        boldFont.setBold(True)
        self.header.rpcClientsBox.addItem("Local Wallet", custom_servers[0])
        self.header.rpcClientsBox.setItemData(self.getServerListIndex(custom_servers[0]), boldFont, Qt.FontRole)
        # Add custom servers
        for s in custom_servers[1:]:
            url = s["protocol"] + "://" + s["host"].split(':')[0]
            self.header.rpcClientsBox.addItem(url, s)
        # reset index
        if self.parent.cache['selectedRPC_index'] >= self.header.rpcClientsBox.count():
            # (if manually removed from the config files) replace default index
            self.parent.cache['selectedRPC_index'] = persistCacheSetting('cache_RPCindex', DefaultCache["selectedRPC_index"])

        self.header.rpcClientsBox.setCurrentIndex(self.parent.cache['selectedRPC_index'])
        self.updatingRPCbox = False
        # reload servers in configure dialog
        self.sig_RPClistReloaded.emit() 
开发者ID:PIVX-Project,项目名称:PIVX-SPMT,代码行数:33,代码来源:mainWindow.py

示例12: data

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

        if not 0 <= index.row() < len(self.sub_signatures):
            return None

        if role == Qt.DisplayRole:
            row = self.sub_signatures.values()[index.row()]
            if row is None:
                return None
            ((start_ea, end_ea, mask_options, custom), notes) = row

            if index.column() == 0:
                if None == start_ea:
                    return '-'
                return '0x{0:08x}'.format(start_ea)

            elif index.column() == 1:
                if None == end_ea:
                    return '-'
                return '0x{0:08x}'.format(end_ea)

            elif index.column() == 2:
                return notes

            elif index.column() == 3:
                if None != mask_options:
                    temp = Assembly(start_ea, end_ea)
                    temp.mask_opcodes_tuple(mask_options)

                    if None != custom:
                        temp.set_opcode_list(custom, True)

                    return ''.join(temp.get_opcode_list()).replace(' ', '')

                return MiscAssembly.sub_signature_string(custom)

            else:
                return None

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

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

        if role == Qt.TextAlignmentRole:
            if index.column() < 2:
                return Qt.AlignCenter;
            return Qt.AlignLeft; 
开发者ID:Cisco-Talos,项目名称:CASC,代码行数:53,代码来源:casc_plugin.py

示例13: data

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

        i, j = index.row(), index.column()

        try:
            lbl = self.display_labels[i]
        except IndexError:
            return None

        if isinstance(lbl, ChecksumLabel) and self.message is not None:
            calculated_crc = lbl.calculate_checksum_for_message(self.message, use_decoded_bits=True)
        else:
            calculated_crc = None

        if role == Qt.DisplayRole:
            if j == 0:
                return lbl.name
            elif j == 1:
                return lbl.color_index
            elif j == 2:
                return lbl.DISPLAY_FORMATS[lbl.display_format_index]
            elif j == 3:
                return lbl.display_order_str
            elif j == 4:
                return self.__display_data(lbl, calculated_crc)
        elif role == Qt.CheckStateRole and j == 0:
            return lbl.show
        elif role == Qt.BackgroundColorRole:
            if isinstance(lbl, ChecksumLabel) and j == 4 and self.message is not None:
                start, end = self.message.get_label_range(lbl, 0, True)
                if calculated_crc == self.message.decoded_bits[start:end]:
                    return settings.BG_COLOR_CORRECT
                else:
                    return settings.BG_COLOR_WRONG

            else:
                return None

        elif role == Qt.ToolTipRole:
            if j == 2:
                return self.tr("Choose display type for the value of the label:"
                               "<ul>"
                               "<li>Bit</li>"
                               "<li>Hexadecimal (Hex)</li>"
                               "<li>ASCII chars</li>"
                               "<li>Decimal Number</li>"
                               "<li>Binary Coded Decimal (BCD)</li>"
                               "</ul>")
            if j == 3:
                return self.tr("Choose bit order for the displayed value:"
                               "<ul>"
                               "<li>Most Significant Bit (MSB) [Default]</li>"
                               "<li>Least Significant Bit (LSB)</li>"
                               "<li>Least Significant Digit (LSD)</li>"
                               "</ul>")
        elif role == Qt.FontRole and j == 0:
            font = QFont()
            font.setBold(i in self.selected_label_indices)
            return font 
开发者ID:jopohl,项目名称:urh,代码行数:63,代码来源:LabelValueTableModel.py

示例14: data

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

        i = index.row()
        j = index.column()
        if role == Qt.DisplayRole and self.display_data:
            try:
                alignment_offset = self.get_alignment_offset_at(i)
                if j < alignment_offset:
                    return self.ALIGNMENT_CHAR

                if self.proto_view == 0:
                    return self.display_data[i][j - alignment_offset]
                elif self.proto_view == 1:
                    return "{0:x}".format(self.display_data[i][j - alignment_offset])
                elif self.proto_view == 2:
                    return chr(self.display_data[i][j - alignment_offset])
            except IndexError:
                return None

        elif role == Qt.TextAlignmentRole:
            if i in self.first_messages:
                return Qt.AlignHCenter + Qt.AlignBottom
            else:
                return Qt.AlignCenter

        elif role == Qt.BackgroundColorRole:
            return self.background_colors[i, j]

        elif role == Qt.FontRole:
            font = QFont()
            font.setBold(self.bold_fonts[i, j])
            font.setItalic(self.italic_fonts[i, j])
            return font

        elif role == Qt.TextColorRole:
            return self.text_colors[i, j]

        elif role == Qt.ToolTipRole:
            return self.get_tooltip(i, j)
        else:
            return None 
开发者ID:jopohl,项目名称:urh,代码行数:45,代码来源:TableModel.py

示例15: test_checksum_in_generation_tab

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import FontRole [as 别名]
def test_checksum_in_generation_tab(self):
        self.add_signal_to_form("esaver.complex16s")
        self.form.signal_tab_controller.signal_frames[0].ui.spinBoxCenterOffset.setValue(0.3692)
        self.form.signal_tab_controller.signal_frames[0].ui.spinBoxCenterOffset.editingFinished.emit()

        self.form.compare_frame_controller.add_protocol_label(4, 6, 0, 1, edit_label_name=False)
        checksum_fieldtype = next(
            ft for ft in self.form.compare_frame_controller.field_types if ft.function == ft.Function.CHECKSUM)

        label_model = self.form.compare_frame_controller.label_value_model
        label_model.setData(label_model.index(0, 0), checksum_fieldtype.caption, Qt.EditRole)

        gframe = self.form.generator_tab_controller
        gframe.ui.cbViewType.setCurrentIndex(1)
        self.add_signal_to_generator(signal_index=0)
        self.assertEqual(gframe.table_model.row_count, 3)
        self.assertEqual(gframe.table_model.protocol.protocol_labels[0].field_type, checksum_fieldtype)

        # check font is italic
        for i in range(3):
            for j in range(len(gframe.table_model.display_data[i])):
                font = gframe.table_model.data(gframe.table_model.createIndex(i, j), Qt.FontRole)
                if 4 <= j <= 6:
                    self.assertTrue(font.italic(), msg=str(j))
                else:
                    self.assertFalse(font.italic(), msg=str(j))

        # Now change something and verify CRC gets recalced
        checksum_before = gframe.table_model.display_data[0][4:6]
        self.assertNotEqual(gframe.table_model.data(gframe.table_model.index(0, 1)), "f")
        gframe.table_model.setData(gframe.table_model.index(0, 1), "f", Qt.EditRole)
        checksum_after = gframe.table_model.display_data[0][4:6]
        self.assertNotEqual(checksum_before, checksum_after)

        # change something behind data ranges, crc should stay the same
        checksum_before = gframe.table_model.display_data[1][4:6]
        self.assertNotEqual(gframe.table_model.data(gframe.table_model.index(1, 10)), "b")
        gframe.table_model.setData(gframe.table_model.index(1, 10), "b", Qt.EditRole)
        checksum_after = gframe.table_model.display_data[1][4:6]
        self.assertNotEqual(checksum_before, checksum_after)

        # edit checksum and verify its not italic anymore
        gframe.table_model.setData(gframe.table_model.index(2, 5), "c", Qt.EditRole)
        for i in range(3):
            for j in range(len(gframe.table_model.display_data[i])):
                font = gframe.table_model.data(gframe.table_model.createIndex(i, j), Qt.FontRole)
                if 4 <= j <= 6 and i != 2:
                    self.assertTrue(font.italic(), msg=str(j))
                else:
                    self.assertFalse(font.italic(), msg=str(j)) 
开发者ID:jopohl,项目名称:urh,代码行数:52,代码来源:test_crc_gui_integration.py


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