當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QFont方法代碼示例

本文整理匯總了Python中PyQt5.QtGui.QFont方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QFont方法的具體用法?Python QtGui.QFont怎麽用?Python QtGui.QFont使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtGui的用法示例。


在下文中一共展示了QtGui.QFont方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_format_from_style

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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 
開發者ID:amimo,項目名稱:dcc,代碼行數:26,代碼來源:sourcewindow.py

示例2: __init__

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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() 
開發者ID:aroberge,項目名稱:easygui_qt,代碼行數:21,代碼來源:easygui_qt.py

示例3: boxclose

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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() 
開發者ID:arpitj07,項目名稱:Python-GUI,代碼行數:19,代碼來源:Project.py

示例4: setupUi

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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) 
開發者ID:arpitj07,項目名稱:Python-GUI,代碼行數:24,代碼來源:scorewidnow.py

示例5: __init__

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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() 
開發者ID:MTG,項目名稱:dunya-desktop,代碼行數:26,代碼來源:table.py

示例6: __init__

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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) 
開發者ID:mtivadar,項目名稱:qiew,代碼行數:22,代碼來源:Banners.py

示例7: __init__

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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) 
開發者ID:mtivadar,項目名稱:qiew,代碼行數:25,代碼來源:elf.py

示例8: __init__

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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) 
開發者ID:HuberTRoy,項目名稱:MusicBox,代碼行數:25,代碼來源:player.py

示例9: getXMLFont

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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 
開發者ID:cedricp,項目名稱:ddt4all,代碼行數:21,代碼來源:uiutils.py

示例10: jsonFont

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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 
開發者ID:cedricp,項目名稱:ddt4all,代碼行數:27,代碼來源:uiutils.py

示例11: __init__

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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() 
開發者ID:matzman666,項目名稱:PyPipboyApp,代碼行數:18,代碼來源:globalmapwidget.py

示例12: __init__

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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]) 
開發者ID:amimo,項目名稱:dcc,代碼行數:17,代碼來源:sourcewindow.py

示例13: set_text_font

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
def set_text_font(self):
        font = QtGui.QFont()
        font.setFamily('Arial')
        font.setFixedPitch(False)
        font.setPointSize(12)
        self.editor.setFont(font) 
開發者ID:aroberge,項目名稱:easygui_qt,代碼行數:8,代碼來源:show_text_window.py

示例14: set_monospace_font

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
def set_monospace_font(self):
        font = QtGui.QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(12)
        self.editor.setFont(font) 
開發者ID:aroberge,項目名稱:easygui_qt,代碼行數:8,代碼來源:show_text_window.py

示例15: __init__

# 需要導入模塊: from PyQt5 import QtGui [as 別名]
# 或者: from PyQt5.QtGui import QFont [as 別名]
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)) 
開發者ID:aroberge,項目名稱:easygui_qt,代碼行數:30,代碼來源:show_text_window.py


注:本文中的PyQt5.QtGui.QFont方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。