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


Python QtGui.QFontDatabase类代码示例

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


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

示例1: create_encrypt_tab

    def create_encrypt_tab(self):
        w = QWidget()

        layout = QGridLayout(w)

        message_e = QTextEdit()
        layout.addWidget(QLabel(_('Message')), 1, 0)
        layout.addWidget(message_e, 1, 1)
        layout.setRowStretch(2, 2)

        recipient_e = QTextEdit()
        recipient_e.setPlaceholderText('''-----BEGIN PGP PUBLIC KEY BLOCK-----''')
        recipient_e.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont))
        layout.addWidget(QLabel(_('Recipient key')), 2, 0)
        layout.addWidget(recipient_e, 2, 1)

        encrypted_e = QTextEdit()
        encrypted_e.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont))
        layout.addWidget(QLabel(_('Encrypted')), 3, 0)
        layout.addWidget(encrypted_e, 3, 1)
        layout.setRowStretch(3, 1)

        hbox = QHBoxLayout()
        b = QPushButton(_('Encrypt'))
        b.clicked.connect(lambda: self.do_encrypt(message_e, recipient_e, encrypted_e))
        hbox.addWidget(b)

        b = QPushButton(_('Decrypt'))
        b.clicked.connect(lambda: self.do_decrypt(encrypted_e, message_e))
        hbox.addWidget(b)

        layout.addLayout(hbox, 4, 1)
        return w
开发者ID:asfin,项目名称:electrum,代码行数:33,代码来源:qt.py

示例2: seed_img

    def seed_img(self, is_seed = True):

        if is_seed:
            try:
                cseed = self.get_seed()
            except UserCancelled:
                return
            except InvalidPassword as e:
                self.d.show_error(str(e))
                return
            if not cseed:
                self.d.show_message(_("This wallet has no seed"))
                return
            txt = cseed.upper()
        else:
            txt = self.txt.upper()

        img = QImage(self.SIZE[0], self.SIZE[1], QImage.Format_Mono)
        bitmap = QBitmap.fromImage(img, Qt.MonoOnly)
        bitmap.fill(Qt.white)
        painter = QPainter()
        painter.begin(bitmap)
        QFontDatabase.addApplicationFont(os.path.join(os.path.dirname(__file__), 'SourceSansPro-Bold.otf') )
        if len(txt) < 102 :
            fontsize = 15
            linespace = 15
            max_letters = 17
            max_lines = 6
            max_words = 3
        else:
            fontsize = 12
            linespace = 10
            max_letters = 21
            max_lines = 9
            max_words = int(max_letters/4)

        font = QFont('Source Sans Pro', fontsize, QFont.Bold)
        font.setLetterSpacing(QFont.PercentageSpacing, 100)
        font.setPixelSize(fontsize)
        painter.setFont(font)
        seed_array = txt.split(' ')

        for n in range(max_lines):
            nwords = max_words
            temp_seed = seed_array[:nwords]
            while len(' '.join(map(str, temp_seed))) > max_letters:
               nwords = nwords - 1
               temp_seed = seed_array[:nwords]
            painter.drawText(QRect(0, linespace*n , self.SIZE[0], self.SIZE[1]), Qt.AlignHCenter, ' '.join(map(str, temp_seed)))
            del seed_array[:nwords]

        painter.end()
        img = bitmap.toImage()
        if (self.rawnoise == False):
            self.make_rawnoise()

        self.make_cypherseed(img, self.rawnoise, False, is_seed)
        return img
开发者ID:vialectrum,项目名称:vialectrum,代码行数:58,代码来源:qt.py

示例3: updateStyle

 def updateStyle(self, fontStyle):
     fontDatabase = QFontDatabase()
     oldStrategy = self.displayFont.styleStrategy()
     self.displayFont = fontDatabase.font(self.displayFont.family(),
             fontStyle, self.displayFont.pointSize())
     self.displayFont.setStyleStrategy(oldStrategy)
     self.squareSize = max(24, QFontMetrics(self.displayFont).xHeight() * 3)
     self.adjustSize()
     self.update()
开发者ID:death-finger,项目名称:Scripts,代码行数:9,代码来源:charactermap.py

示例4: display_content

    def display_content(self):
        #
        layout_main = QVBoxLayout()
        layout_main.setAlignment(Qt.AlignCenter)
        self.setLayout(layout_main)
        self.layouts.append(layout_main)

        #
        fonts = QFontDatabase()
        fonts.addApplicationFont('Fonts/Raleway/Raleway-ExtraLight.ttf')
        fonts.addApplicationFont('Fonts/OpenSans/OpenSans-Light.ttf')

        #
        title = QLabel("Eight Puzzle")
        title.setStyleSheet('font-size: 52px; color: #CECFD4;')
        title.setFont(QFont('Raleway'))
        layout_main.addWidget(title)
        layout_main.addSpacerItem(QSpacerItem(0, 12))

        #
        layout_tiles = QGridLayout()
        layout_tiles.setAlignment(Qt.AlignCenter)
        layout_main.addLayout(layout_tiles)
        for index in range(9):
            tile = QPushButton(str(self.puzzle.state[index]))
            tile.setStyleSheet('background-color: #879AA4;'
                               'color: #CECFD4; font-size: 32px;')
            tile.setFont(QFont('Open Sans'))
            tile.setFixedSize(75, 75)
            tile.setEnabled(False)
            tile.setFocusPolicy(Qt.NoFocus)
            layout_tiles.addWidget(tile, index / 3, index % 3)
            if self.puzzle.state[index] is '0':
                tile.setVisible(False)
            self.tiles.append(tile)
        self.layouts.append(layout_tiles)
        layout_main.addSpacerItem(QSpacerItem(0, 25))

        #
        layout_buttons = QGridLayout()
        layout_buttons.setAlignment(Qt.AlignCenter)
        layout_main.addLayout(layout_buttons)
        for index in range(3):
            button = QPushButton(['Shuffle', 'Solve', 'Quit'][index])
            button.setStyleSheet('background-color: #CECFD4;'
                                 'color: #363B57; font-size: 18px;')
            button.setFont(QFont('Raleway'))
            button.setFixedSize(90, 40)
            button.setFocusPolicy(Qt.NoFocus)
            layout_buttons.addWidget(button, 0, index)
            self.buttons.append(button)
        self.layouts.append(layout_buttons)
        layout_main.addSpacerItem(QSpacerItem(0, 10))
开发者ID:nsteely,项目名称:Eight-Puzzle,代码行数:53,代码来源:eight_puzzle_qt.py

示例5: findStyles

    def findStyles(self, font):
        fontDatabase = QFontDatabase()
        currentItem = self.styleCombo.currentText()
        self.styleCombo.clear()

        for style in fontDatabase.styles(font.family()):
            self.styleCombo.addItem(style)

        styleIndex = self.styleCombo.findText(currentItem)
        if styleIndex == -1:
            self.styleCombo.setCurrentIndex(0)
        else:
            self.styleCombo.setCurrentIndex(styleIndex)
开发者ID:death-finger,项目名称:Scripts,代码行数:13,代码来源:charactermap.py

示例6: __init__

    def __init__(self):
        super(MainWindow, self).__init__()

        font_id = QFontDatabase.addApplicationFont("fontawesome-webfont.ttf")

        if font_id is not -1:
            font_db = QFontDatabase()
            self.font_styles = font_db.styles('FontAwesome')
            self.font_families = QFontDatabase.applicationFontFamilies(font_id)
            print(self.font_styles, self.font_families)
            for font_family in self.font_families:
                self.font = font_db.font(font_family, self.font_styles[0], 18)
        self.home()
开发者ID:sdouglas,项目名称:lr-notebook,代码行数:13,代码来源:qtfa.py

示例7: __init__

    def __init__(self, parent):
        super().__init__(parent)

        font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        font.setPointSize(8)
        self.setFont(font)
        self.setPlainText("...")
开发者ID:jopohl,项目名称:urh,代码行数:7,代码来源:UnlabeledRangeItem.py

示例8: create_signature_tab

    def create_signature_tab(self):
        w = QWidget()

        layout = QGridLayout(w)

        message_e = QTextEdit()
        layout.addWidget(QLabel(_('Message')), 1, 0)
        layout.addWidget(message_e, 1, 1)
        layout.setRowStretch(2, 2)

        encrypted_e = QTextEdit()
        encrypted_e.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont))
        layout.addWidget(QLabel(_('Signed')), 2, 0)
        layout.addWidget(encrypted_e, 2, 1)
        layout.setRowStretch(2, 2)

        hbox = QHBoxLayout()
        b = QPushButton(_('Sign'))
        b.clicked.connect(lambda: self.do_sign(message_e, encrypted_e))
        hbox.addWidget(b)

        b = QPushButton(_('Verify'))
        b.clicked.connect(lambda: self.do_verify(encrypted_e, message_e))
        hbox.addWidget(b)

        layout.addLayout(hbox, 3, 1)
        return w
开发者ID:asfin,项目名称:electrum,代码行数:27,代码来源:qt.py

示例9: __init__

    def __init__(self, app, parent=None):
        super().__init__(parent)

        self._app = app
        # self.setPlaceholderText('搜索歌曲、歌手、专辑、用户;执行 Python 代码等')
        self.setPlaceholderText('Search library, exec code, or run command.')
        self.setToolTip('直接输入文字可以进行过滤,按 Enter 可以搜索\n'
                        '输入 >>> 前缀之后,可以执行 Python 代码\n'
                        '输入 $ 前缀可以执行 fuo 命令(未实现,欢迎 PR)')
        self.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont))

        # 模拟 QLineEdit
        self.setTabChangesFocus(True)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setWordWrapMode(QTextOption.NoWrap)
        self.setFixedHeight(self.sizeHint().height())
        self.setMinimumHeight(25)

        self._timer = QTimer(self)
        self._cmd_text = None
        self._mode = 'cmd'  # 详见 _set_mode 函数
        self._timer.timeout.connect(self.__on_timeout)

        self.textChanged.connect(self.__on_text_edited)
        self._highlighter = Highlighter(self.document())
        # self.textEdited.connect(self.__on_text_edited)
        self.returnPressed.connect(self.__on_return_pressed)
开发者ID:BruceZhang1993,项目名称:FeelUOwn,代码行数:28,代码来源:magicbox.py

示例10: __init__

    def __init__(self, name, timeValue):
        super(QDialog, self).__init__()
        self.resize(300, 150)

        timeContainer = QGroupBox()
        timeContainer.setTitle('Time (ms)')

        self.lineEdit = QLineEdit()
        fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        self.lineEdit.setFont(fixedWidthFont)
        self.lineEdit.setText(str(timeValue))
        vLayout = QVBoxLayout()
        vLayout.addWidget(self.lineEdit)

        self.cancelButton = QPushButton()
        self.cancelButton.setText('Cancel')
        self.cancelButton.clicked.connect(self.cancelClicked)

        self.acceptButton = QPushButton()
        self.acceptButton.setText('Accept')
        self.acceptButton.clicked.connect(self.acceptClicked)

        buttonContainer = QWidget()
        hLayout = QHBoxLayout()
        hLayout.addWidget(self.cancelButton)
        hLayout.addWidget(self.acceptButton)
        buttonContainer.setLayout(hLayout)
        vLayout.addWidget(buttonContainer)
        timeContainer.setLayout(vLayout)

        vLayout2 = QVBoxLayout()
        vLayout2.addWidget(timeContainer)
        self.setLayout(vLayout2)
开发者ID:Diegojnb,项目名称:JdeRobot,代码行数:33,代码来源:timerdialog.py

示例11: drawWindow

    def drawWindow(self):
        if self.layout() is not None:
            tempWidget = QWidget()
            tempWidget.setLayout(self.layout())

        gridLayout = QGridLayout()

        # add header
        gridLayout.addWidget(QLabel('Libraries'), 0, 0)
        gridLayout.addWidget(QLabel(''), 0, 1)

        # add new library edit box
        self.libraryNameEdit = QLineEdit()
        fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        self.libraryNameEdit.setFont(fixedWidthFont)
        gridLayout.addWidget(self.libraryNameEdit, 1, 0)
        self.addButton = QPushButton('Add')
        self.addButton.clicked.connect(self.addClicked)
        gridLayout.addWidget(self.addButton, 1, 1)

        self.buttons = {}

        row = 2
        for lib in self.libraries:
            gridLayout.addWidget(QLabel(lib), row, 0)
            deleteButton = QPushButton()
            deleteButton.setObjectName(lib)
            deleteButton.setText('Delete')
            deleteButton.clicked.connect(self.deleteButtonClicked)
            gridLayout.addWidget(deleteButton, row, 1)
            row += 1
            self.buttons[deleteButton] = lib

        self.resize(300, 100)
        self.setLayout(gridLayout)
开发者ID:Diegojnb,项目名称:JdeRobot,代码行数:35,代码来源:librariesdialog.py

示例12: __init__

    def __init__(self, name, currentValue):
        super(QDialog, self).__init__()
        self.setWindowTitle(name)
        self.resize(800, 600)
        self.codeEdit = QsciScintilla()
        self.codeEdit.setText(currentValue)
        fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        self.codeEdit.setFont(fixedWidthFont)
        fontmetrics = QFontMetrics(fixedWidthFont)
        self.codeEdit.setMarginWidth(0, fontmetrics.width("000"))
        self.codeEdit.setMarginLineNumbers(0, True)
        self.codeEdit.setMarginsBackgroundColor(QColor("#cccccc"))

        self.codeEdit.setBraceMatching(QsciScintilla.SloppyBraceMatch)
        self.codeEdit.setCaretLineVisible(True)
        self.codeEdit.setCaretLineBackgroundColor(QColor("#ffe4e4"))
        lexer = QsciLexerPython()
        lexer.setDefaultFont(fixedWidthFont)
        self.codeEdit.setLexer(lexer)
        self.codeEdit.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
        self.codeEdit.setUtf8(True)

        self.codeEdit.setTabWidth(4)
        self.codeEdit.setIndentationsUseTabs(True)
        self.codeEdit.setIndentationGuides(True)
        self.codeEdit.setTabIndents(True)
        self.codeEdit.setAutoIndent(True)

        self.cancelButton = QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.cancel)
        self.acceptButton = QPushButton('Accept')
        self.acceptButton.clicked.connect(self.accept)

        self.pythonButton = QRadioButton('Python')
        self.pythonButton.setChecked(True)
        self.pythonButton.clicked.connect(self.pythonClicked)
        self.cppButton = QRadioButton('C++')
        self.cppButton.clicked.connect(self.cppClicked)

        hLayout0 = QHBoxLayout()
        hLayout0.addWidget(self.pythonButton)
        hLayout0.addWidget(self.cppButton)
        container0 = QWidget()
        container0.setLayout(hLayout0)

        verticalLayout = QVBoxLayout()
        verticalLayout.addWidget(container0)
        verticalLayout.addWidget(self.codeEdit)

        container = QWidget()
        hLayout =QHBoxLayout()
        hLayout.addWidget(self.cancelButton)
        hLayout.addWidget(self.acceptButton)
        container.setLayout(hLayout)

        verticalLayout.addWidget(container)
        self.setLayout(verticalLayout)

        self.language = 'python'
开发者ID:Diegojnb,项目名称:JdeRobot,代码行数:59,代码来源:codedialog.py

示例13: __init__

    def __init__(self, buf, parent=None):
        super(HexViewWidget, self).__init__()
        self.setupUi(self)
        self._buf = buf
        self._model = HexTableModel(self._buf)

        self._colored_regions = intervaltree.IntervalTree()
        self._origins = []

        # ripped from pyuic5 ui/hexview.ui
        #   at commit 6c9edffd32706097d7eba8814d306ea1d997b25a
        # so we can add our custom HexTableView instance
        self.view = HexTableView(self)
        sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.view.sizePolicy().hasHeightForWidth())
        self.view.setSizePolicy(sizePolicy)
        self.view.setMinimumSize(QSize(660, 0))
        self.view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.view.setSelectionMode(QAbstractItemView.NoSelection)
        self.view.setShowGrid(False)
        self.view.setWordWrap(False)
        self.view.setObjectName("view")
        self.view.horizontalHeader().setDefaultSectionSize(25)
        self.view.horizontalHeader().setMinimumSectionSize(25)
        self.view.verticalHeader().setDefaultSectionSize(21)
        self.mainLayout.insertWidget(0, self.view)
        # end rip

        # TODO: provide a HexViewWidget.setModel method, and don't build it ourselves
        self.view.setModel(self._model)
        for i in range(0x10):
            self.view.setColumnWidth(i, 25)
        self.view.setColumnWidth(0x10, 12)
        for i in range(0x11, 0x22):
            self.view.setColumnWidth(i, 11)

        self._hsm = HexItemSelectionModel(self._model, self.view)
        self.view.setSelectionModel(self._hsm)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self._handle_context_menu_requested)

        self._hsm.selectionRangeChanged.connect(self._handle_selection_range_changed)

        self.originsChanged.connect(self._handle_origins_changed)

        self.view.moveKeyPressed.connect(self._hsm.handle_move_key)
        self.view.selectKeyPressed.connect(self._hsm.handle_select_key)

        f = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        self.view.setFont(f)
        self.statusLabel.setFont(f)

        self.view.setItemDelegate(HexItemDelegate(self._model, self))

        self.statusLabel.setText("")
开发者ID:williballenthin,项目名称:python-pyqt5-hexview,代码行数:59,代码来源:hexview.py

示例14: family

 def family(self):
     return idaapi.reg_read_string(
         'Name',
         self._key,
         'Consolas'
         if os.name == 'nt' else 
         QFontDatabase.systemFont(QFontDatabase.FixedFont).family().encode()    
     )
开发者ID:zyantific,项目名称:IDASkins,代码行数:8,代码来源:idafontconfig.py

示例15: __init__

    def __init__(self, name):
        super(QDialog, self).__init__()
        self.setWindowTitle(name)
        self.config = None

        self.gridLayout = QGridLayout()

        # add header
        self.gridLayout.addWidget(QLabel('Server Type'), 0, 0)
        self.gridLayout.addWidget(QLabel('Name'), 0, 1)
        self.gridLayout.addWidget(QLabel('Topic'), 0, 2)
        self.gridLayout.addWidget(QLabel('Proxy Name'), 0, 3)
        self.gridLayout.addWidget(QLabel('IP'), 0, 4)
        self.gridLayout.addWidget(QLabel('Port'), 0, 5)
        self.gridLayout.addWidget(QLabel('Interface'), 0, 6)
        self.gridLayout.addWidget(QLabel(''), 0, 7)

        # add new config input fields
        fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        self.serverTypeCombo = QComboBox()
        self.serverTypeCombo.setFont(fixedWidthFont)
        self.gridLayout.addWidget(self.serverTypeCombo, 1, 0)
        self.nameEdit = QLineEdit()
        self.nameEdit.setFont(fixedWidthFont)
        self.gridLayout.addWidget(self.nameEdit, 1, 1)
        self.topicEdit = QLineEdit()
        self.topicEdit.setFont(fixedWidthFont)
        self.topicEdit.setEnabled(False)
        self.gridLayout.addWidget(self.topicEdit, 1, 2)
        self.proxyNameEdit = QLineEdit()
        self.proxyNameEdit.setFont(fixedWidthFont)
        self.gridLayout.addWidget(self.proxyNameEdit, 1, 3)
        self.ipEdit = QLineEdit()
        self.ipEdit.setFont(fixedWidthFont)
        self.gridLayout.addWidget(self.ipEdit, 1, 4)
        self.portEdit = QLineEdit()
        self.portEdit.setFont(fixedWidthFont)
        self.gridLayout.addWidget(self.portEdit, 1, 5)
        self.interfaceCombo = QComboBox()
        self.gridLayout.addWidget(self.interfaceCombo, 1, 6)
        self.addButton = QPushButton('Add')
        self.gridLayout.addWidget(self.addButton, 1, 7)
        self.addButton.clicked.connect(self.addClicked)

        self.rowCount = 2

        # add server types to the combobox
        self.serverTypeCombo.addItem('ICE', 'ice')
        self.serverTypeCombo.addItem('ROS', 'ros')
        self.serverTypeCombo.currentIndexChanged.connect(self.serverTypeChanged)

        # add interfaces to the combobox
        interfaces = Interfaces.getInterfaces()
        for interfaceName in interfaces:
            self.interfaceCombo.addItem(interfaceName, interfaceName)

        self.resize(700, 100)
        self.setLayout(self.gridLayout)
开发者ID:Diegojnb,项目名称:JdeRobot,代码行数:58,代码来源:jderobotcommconfigdialog.py


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