Python源码示例:PyQt5.QtGui.QFont()

示例1
def __init__(self):
        super(SimpleApp, self).__init__([])

        self.translator = QtCore.QTranslator()
        self.default_font = QtGui.QFont()

        if sys.version_info < (3,) :
            settings_path = ".easygui-qt2"
        else:
            settings_path = ".easygui-qt3"
        self.config_path = os.path.join(os.path.expanduser("~"),
                                         settings_path)
        try:
            self.load_config()
            self.setFont(self.default_font)
        except:
            pass

        self.save_config() 
示例2
def _get_format_from_style(self, token, style):
        """ Returns a QTextCharFormat for token by reading a Pygments style.
        """
        result = QtGui.QTextCharFormat()
        for key, value in list(style.style_for_token(token).items()):
            if value:
                if key == 'color':
                    result.setForeground(self._get_brush(value))
                elif key == 'bgcolor':
                    result.setBackground(self._get_brush(value))
                elif key == 'bold':
                    result.setFontWeight(QtGui.QFont.Bold)
                elif key == 'italic':
                    result.setFontItalic(True)
                elif key == 'underline':
                    result.setUnderlineStyle(
                        QtGui.QTextCharFormat.SingleUnderline)
                elif key == 'sans':
                    result.setFontStyleHint(QtGui.QFont.SansSerif)
                elif key == 'roman':
                    result.setFontStyleHint(QtGui.QFont.Times)
                elif key == 'mono':
                    result.setFontStyleHint(QtGui.QFont.TypeWriter)
        return result 
示例3
def boxclose(self):
        teamname = self.open_screen.OpenTheTeam.text()
        myteam= sqlite3.connect('TEAM.db')
        curser= myteam.cursor()
        curser.execute("SELECT PLAYERS from team WHERE NAMES= '"+teamname+"';")
        hu= curser.fetchall()
        self.listWidget.clear()
        for i in range(len(hu)):
            item= QtWidgets.QListWidgetItem(hu[i][0])
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            item.setFont(font)
            item.setBackground(QtGui.QColor('sea green'))
            self.listWidget.addItem(item)
            
        self.openDialog.close() 
示例4
def setupUi(self, ScoreWindow):
        ScoreWindow.setObjectName("ScoreWindow")
        ScoreWindow.resize(471, 386)
        self.centralwidget = QtWidgets.QWidget(ScoreWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.Score = QtWidgets.QLineEdit(self.centralwidget)
        self.Score.setGeometry(QtCore.QRect(180, 180, 113, 22))
        self.Score.setObjectName("Score")
        self.teamscore = QtWidgets.QLabel(self.centralwidget)
        self.teamscore.setGeometry(QtCore.QRect(180, 130, 151, 20))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.teamscore.setFont(font)
        self.teamscore.setObjectName("teamscore")
        ScoreWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(ScoreWindow)
        self.statusbar.setObjectName("statusbar")
        ScoreWindow.setStatusBar(self.statusbar)

        self.retranslateUi(ScoreWindow)
        QtCore.QMetaObject.connectSlotsByName(ScoreWindow) 
示例5
def __init__(self, parent=None):
        QTableView.__init__(self, parent=parent)

        # setting the table for no edit and row selection
        self.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)
        # self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.setMouseTracking(True)
        self.horizontalHeader().setStretchLastSection(True)
        font = QFont()
        font.setPointSize(13)
        self.horizontalHeader().setFont(font)

        # hiding the vertical headers
        self.verticalHeader().hide()

        # arranging the artist column for being multi-line
        self.setWordWrap(True)
        self.setTextElideMode(Qt.ElideMiddle)

        self._last_index = QPersistentModelIndex()
        self.viewport().installEventFilter(self)

        self._set_font() 
示例6
def __init__(self, dataModel, viewMode):
        self.width = 0
        self.height = 0
        self.dataModel = dataModel
        self.viewMode = viewMode
        self.qpix = self._getNewPixmap(self.width, self.height)
        self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))        
        

        # text font
        self.font = QtGui.QFont('Terminus', 11, QtGui.QFont.Light)

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self.fontWidth  = fm.width('a')
        self.fontHeight = fm.height()

        self.textPen = QtGui.QPen(QtGui.QColor(192, 192, 192), 0, QtCore.Qt.SolidLine) 
示例7
def __init__(self, dataModel, viewMode):
        self.width = 0
        self.height = 0
        self.dataModel = dataModel
        self.viewMode = viewMode

        self.qpix = self._getNewPixmap(self.width, self.height)
        self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))        
        

        # text font
        self.font = QtGui.QFont('Consolas', 11, QtGui.QFont.Light)

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self.fontWidth  = fm.width('a')
        self.fontHeight = fm.height()

        self.textPen = QtGui.QPen(QtGui.QColor(255, 255, 0), 0, QtCore.Qt.SolidLine) 
示例8
def __init__(self, dataModel, viewMode):
        self.width = 0
        self.height = 0
        self.dataModel = dataModel
        self.viewMode = viewMode

        self.qpix = self._getNewPixmap(self.width, self.height)
        self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))        
        

        # text font
        self.font = QtGui.QFont('Terminus', 11, QtGui.QFont.Bold)

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self.fontWidth  = fm.width('a')
        self.fontHeight = fm.height()

        self.textPen = QtGui.QPen(QtGui.QColor(255, 255, 0), 0, QtCore.Qt.SolidLine) 
示例9
def __init__(self, dataModel, viewMode, elfplugin):
        self.width = 0
        self.height = 0
        self.dataModel = dataModel
        self.viewMode = viewMode
        self.qpix = self._getNewPixmap(self.width, self.height)
        self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))

        self.elfplugin = elfplugin

        self.elf = self.elfplugin.elf        

        # text font
        self.font = QtGui.QFont('Terminus', 11, QtGui.QFont.Bold)

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self.fontWidth  = fm.width('a')
        self.fontHeight = fm.height()

        self.textPen = QtGui.QPen(QtGui.QColor(192, 192, 192), 0, QtCore.Qt.SolidLine) 
示例10
def __init__(self, parent=None):
        super(DesktopLyric, self).__init__()
        self.lyric = QString('Lyric Show.')
        self.intervel = 0
        self.maskRect = QRectF(0, 0, 0, 0)
        self.maskWidth = 0
        self.widthBlock = 0
        self.t = QTimer()
        self.screen = QApplication.desktop().availableGeometry()
        self.setObjectName(_fromUtf8("Dialog"))
        self.setWindowFlags(Qt.CustomizeWindowHint | Qt.FramelessWindowHint | Qt.Dialog | Qt.WindowStaysOnTopHint | Qt.Tool)
        self.setMinimumHeight(65)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.handle = lyric_handle(self)
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.font = QFont(_fromUtf8('微软雅黑, verdana'), 50)
        self.font.setPixelSize(50)
        # QMetaObject.connectSlotsByName(self)
        self.handle.lyricmoved.connect(self.newPos)
        self.t.timeout.connect(self.changeMask) 
示例11
def getXMLFont(xml, scale = 1):
    font = getChildNodesByName(xml, "Font")[0]
    font_name = font.getAttribute("Name")
    font_size = float(font.getAttribute("Size").replace(',', '.'))
    font_bold = font.getAttribute("Bold")
    font_italic = font.getAttribute("Italic")

    if font_bold == '1':
        fnt_flags = gui.QFont.Bold
    else:
        fnt_flags = gui.QFont.Normal

    if font_italic == '1':
        fnt_flags |= gui.QFont.StyleItalic

    font_size = font_size / float(scale) * 14.
    qfnt = gui.QFont(font_name, font_size, fnt_flags)
    qfnt.setPixelSize(font_size)
    return qfnt 
示例12
def jsonFont(fnt, scale):
    font_name = fnt['name']
    font_size = fnt['size']
    if 'bold' in fnt:
        font_bold = fnt['bold']
    else:
        font_bold = '0'
    if 'italic' in fnt:
        font_italic = fnt['italic']
    else:
        font_italic = '0'

    if font_bold == '1':
        fnt_flags = gui.QFont.Bold
    else:
        fnt_flags = gui.QFont.Normal

    if font_italic == '1':
        fnt_flags |= gui.QFont.StyleItalic

    font_size = font_size / float(scale) * 14.

    qfnt = gui.QFont(font_name, font_size, fnt_flags);
    qfnt.setPixelSize(font_size)
    return qfnt 
示例13
def __init__(self, widget, imageFactory, color, size, parent = None):
        super().__init__(widget.mapScene, widget.mapView, parent)
        self.markerType = 2
        self.uid = 'powerarmormarker'
        self.widget = widget
        self.imageFactory = imageFactory
        self.imageFilePath = os.path.join('res', 'mapmarkerpowerarmor.svg')
        self.pipValueListenerDepth = 1
        self.markerItem.setZValue(0)
        self.setColor(color,False)
        self.setSize(size,False)
        self.setLabelFont(QtGui.QFont("Times", 8, QtGui.QFont.Bold), False)
        self.setLabel('Power Armor', False)
        self.filterVisibleFlag = True
        self.PipVisible = False
        self.doUpdate() 
示例14
def __init__(self, uid, widget, imageFactory, color, size, iconfile='mapmarkerpoi_1.svg', parent = None):
        super().__init__(widget.mapScene, widget.mapView, parent)
        self.markerType = 5
        self.widget = widget
        self.imageFactory = imageFactory
        self.imageFilePath = iconfile
        self.pipValueListenerDepth = 1
        self.markerItem.setZValue(0)
        self.setColor(color,False)
        self.setSize(size,False)
        self.setLabelFont(QtGui.QFont("Times", 8, QtGui.QFont.Bold), False)
        self.setLabel('Point of Interest Marker', False)
        self.filterVisibleFlag = True
        self.uid = str(uid)
        self.thisCharOnly = True

        self.doUpdate() 
示例15
def __init__(self, uid, widget, imageFactory, color, size, parent = None, icon='StarFilled.svg'):
        super().__init__(widget.mapScene, widget.mapView, parent)
        self.markerType = 6
        self.widget = widget
        self.imageFactory = imageFactory
        self.imageFilePath = os.path.join(icon)
        self.markerItem.setZValue(0)
        self.setColor(color,False)
        self.setSize(size, False)
        if self.color is not None:
            self.uncollectedColor = QtGui.QColor.fromRgb(self.color.red(), self.color.green(), self.color.blue())
            self.collectedColor = self.color.darker(200)
        self.setLabelFont(QtGui.QFont("Times", 8, QtGui.QFont.Bold), False)
        self.setLabel('Collectable Marker', False)
        self.filterVisibleFlag = True
        self.uid = uid
        self.collected = False
        self.itemFormID = None
        self.collectedOverlayIcon = None
        self._rebuildOverlayIcons()
        self.doUpdate() 
示例16
def __init__(self, parent=None, lines=[]):
        super(SourceDocument, self).__init__(parent)
        self.parent = parent

        self.setDefaultFont(QtGui.QFont('Monaco', 9, QtGui.QFont.Light))

        cursor = QtGui.QTextCursor(self)  # position=0x0
        self.binding = {}

        # save the cursor position before each interesting element
        for section, L in lines:
            for t in L:
                if t[0] in BINDINGS_NAMES:
                    self.binding[cursor.position()] = t
                cursor.insertText(t[1]) 
示例17
def set_text_font(self):
        font = QtGui.QFont()
        font.setFamily('Arial')
        font.setFixedPitch(False)
        font.setPointSize(12)
        self.editor.setFont(font) 
示例18
def set_monospace_font(self):
        font = QtGui.QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(12)
        self.editor.setFont(font) 
示例19
def __init__(self, parent=None):
        super(Highlighter, self).__init__(parent)

        keywordFormat = QtGui.QTextCharFormat()
        keywordFormat.setForeground(QtCore.Qt.blue)
        keywordFormat.setFontWeight(QtGui.QFont.Bold)

        keywordPatterns = ["\\b{}\\b".format(k) for k in keyword.kwlist]

        self.highlightingRules = [(QtCore.QRegExp(pattern), keywordFormat)
                for pattern in keywordPatterns]

        classFormat = QtGui.QTextCharFormat()
        classFormat.setFontWeight(QtGui.QFont.Bold)
        self.highlightingRules.append((QtCore.QRegExp("\\bQ[A-Za-z]+\\b"),
                classFormat))

        singleLineCommentFormat = QtGui.QTextCharFormat()
        singleLineCommentFormat.setForeground(QtCore.Qt.gray)
        self.highlightingRules.append((QtCore.QRegExp("#[^\n]*"),
                singleLineCommentFormat))

        quotationFormat = QtGui.QTextCharFormat()
        quotationFormat.setForeground(QtCore.Qt.darkGreen)
        self.highlightingRules.append((QtCore.QRegExp("\".*\""),
                quotationFormat))
        self.highlightingRules.append((QtCore.QRegExp("'.*'"),
                quotationFormat)) 
示例20
def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(400, 300)
        self.label = QtWidgets.QLabel(Form)
        self.label.setGeometry(QtCore.QRect(100, 40, 201, 81))
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setObjectName("label")

        
        self.pushButton = QtWidgets.QPushButton(Form)
        self.pushButton.setGeometry(QtCore.QRect(150, 190, 111, 28))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.pushButton.setFont(font)
        self.pushButton.setObjectName("pushButton")
        
        self.lineEdit = QtWidgets.QLineEdit(Form)
        self.lineEdit.setGeometry(QtCore.QRect(100, 140, 201, 22))
        self.lineEdit.setObjectName("lineEdit")

        
        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form) 
示例21
def combo2(self):
        myteam=sqlite3.connect("TEAM.db")
        cu= myteam.cursor()
        
        team = self.eval_screen.SelectTeam.currentText()
        cu.execute("SELECT PlAYERS from team WHERE NAMES='"+team+"';")
        player= cu.fetchall()
        self.eval_screen.PlayerList.clear()
        for i in range(len(player)):
            item= QtWidgets.QListWidgetItem(player[i][0])
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            item.setFont(font)
            item.setBackground(QtGui.QColor('#ffff99'))
            self.eval_screen.PlayerList.addItem(item)
        
        cu.execute("SELECT SCORES from team WHERE NAMES='"+team+"';")
        score=cu.fetchall()
        self.teamscore=[]
        for i in range(len(score)):
            self.teamscore.append(score[i][0])
    
        self.eval_screen.ScoreList.clear()
        for i in range(len(score)):
            items= QtWidgets.QListWidgetItem(str(score[i][0]))
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            items.setFont(font)
            items.setBackground(QtGui.QColor('#fdc086'))
            self.eval_screen.ScoreList.addItem(items) 
示例22
def get_font_small(i_italics: bool=False, i_bold: bool=False) -> QtGui.QFont:
    font = QtGui.QFont()
    font.setPointSize(9)
    font.setItalic(i_italics)
    font.setBold(i_bold)
    return font 
示例23
def get_font_medium(i_italics: bool=False, i_bold: bool=False) -> QtGui.QFont:
    font = QtGui.QFont()
    font.setItalic(i_italics)
    font.setBold(i_bold)
    return font 
示例24
def get_font_large(i_underscore: bool=False, i_italics: bool=False, i_bold: bool=False) -> QtGui.QFont:
    font = QtGui.QFont()
    font.setPointSize(13)
    font.setUnderline(i_underscore)
    font.setItalic(i_italics)
    font.setBold(i_bold)
    return font 
示例25
def get_font_xlarge(i_underscore: bool=False, i_italics: bool=False, i_bold: bool=False) -> QtGui.QFont:
    font = QtGui.QFont()
    font.setPointSize(16)
    font.setUnderline(i_underscore)
    font.setItalic(i_italics)
    font.setBold(i_bold)
    return font 
示例26
def get_font_xxlarge(i_underscore: bool=False, i_italics: bool=False, i_bold: bool=False) -> QtGui.QFont:
    font = QtGui.QFont()
    font.setPointSize(24)
    font.setUnderline(i_underscore)
    font.setItalic(i_italics)
    font.setBold(i_bold)
    return font 
示例27
def initFontWidget(self):
        self.fontDialog = QFontDialog()
        self.changeFontButton = QPushButton(self)
        self.fontDialog.setCurrentFont(QFont('Sans serif'))
        self.changeFontButton.setText('{0} {1}'.format(self.fontDialog.currentFont().family(),
                                                       self.fontDialog.currentFont().pointSize()))
        self.changeFontButton.clicked.connect(self.fontButtonClicked) 
示例28
def __init__(self, value):
        super(KeepIndicatorTableWidgetItem, self).__init__()
        self.setKeep(value)
        # Use a large font size for the checkboxes
        font = QtGui.QFont()
        font.setPointSize(self.fontSize)
        self.setFont(font) 
示例29
def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(529, 329)
        self.selInfoWidget = QtWidgets.QWidget(Form)
        self.selInfoWidget.setGeometry(QtCore.QRect(260, 10, 264, 222))
        self.selInfoWidget.setObjectName("selInfoWidget")
        self.gridLayout = QtWidgets.QGridLayout(self.selInfoWidget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.selDescLabel = QtWidgets.QLabel(self.selInfoWidget)
        self.selDescLabel.setText("")
        self.selDescLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
        self.selDescLabel.setWordWrap(True)
        self.selDescLabel.setObjectName("selDescLabel")
        self.gridLayout.addWidget(self.selDescLabel, 0, 0, 1, 1)
        self.selNameLabel = QtWidgets.QLabel(self.selInfoWidget)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.selNameLabel.setFont(font)
        self.selNameLabel.setText("")
        self.selNameLabel.setObjectName("selNameLabel")
        self.gridLayout.addWidget(self.selNameLabel, 0, 1, 1, 1)
        self.selectedTree = DataTreeWidget(self.selInfoWidget)
        self.selectedTree.setObjectName("selectedTree")
        self.selectedTree.headerItem().setText(0, "1")
        self.gridLayout.addWidget(self.selectedTree, 1, 0, 1, 2)
        self.hoverText = QtWidgets.QTextEdit(Form)
        self.hoverText.setGeometry(QtCore.QRect(0, 240, 521, 81))
        self.hoverText.setObjectName("hoverText")
        self.view = FlowchartGraphicsView(Form)
        self.view.setGeometry(QtCore.QRect(0, 0, 256, 192))
        self.view.setObjectName("view")

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form) 
示例30
def _set_status_bar(self):
        self.statusbar.setMinimumSize(QtCore.QSize(0, 18))
        font = QFont()
        font.setPointSize(9)
        self.statusbar.setFont(font)