本文整理汇总了Python中PyQt5.Qt.QTextCharFormat.setFontPointSize方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCharFormat.setFontPointSize方法的具体用法?Python QTextCharFormat.setFontPointSize怎么用?Python QTextCharFormat.setFontPointSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTextCharFormat
的用法示例。
在下文中一共展示了QTextCharFormat.setFontPointSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initializeFormats
# 需要导入模块: from PyQt5.Qt import QTextCharFormat [as 别名]
# 或者: from PyQt5.Qt.QTextCharFormat import setFontPointSize [as 别名]
def initializeFormats(self):
Config = self.Config
Config["fontfamily"] = "monospace"
for name, color, bold, italic in (
("normal", "#000000", False, False),
("keyword", "#000080", True, False),
("builtin", "#0000A0", False, False),
("comment", "#007F00", False, True),
("string", "#808000", False, False),
("number", "#924900", False, False),
("lparen", "#000000", True, True),
("rparen", "#000000", True, True)):
Config["%sfontcolor" % name] = color
Config["%sfontbold" % name] = bold
Config["%sfontitalic" % name] = italic
baseFormat = QTextCharFormat()
baseFormat.setFontFamily(Config["fontfamily"])
Config["fontsize"] = gprefs['gpm_template_editor_font_size']
baseFormat.setFontPointSize(Config["fontsize"])
for name in ("normal", "keyword", "builtin", "comment",
"string", "number", "lparen", "rparen"):
format = QTextCharFormat(baseFormat)
format.setForeground(QColor(Config["%sfontcolor" % name]))
if Config["%sfontbold" % name]:
format.setFontWeight(QFont.Bold)
format.setFontItalic(Config["%sfontitalic" % name])
self.Formats[name] = format
示例2: setFontPointSize
# 需要导入模块: from PyQt5.Qt import QTextCharFormat [as 别名]
# 或者: from PyQt5.Qt.QTextCharFormat import setFontPointSize [as 别名]
def setFontPointSize(self, pointSize):
"""Override. Set font size."""
pointSize = float(pointSize)
if pointSize > 0:
undoState = self.isUndoRedoEnabled()
self.setUndoRedoEnabled(False)
mod = self.document().isModified()
fmt = QTextCharFormat()
fmt.setFontPointSize(pointSize)
cursor = self.textCursor()
self.selectAll()
super().setFontPointSize(pointSize)
cursor2 = self.textCursor()
cursor2.clearSelection()
self.setTextCursor(cursor2)
self.setTextCursor(cursor)
self.document().setModified(mod)
self.setUndoRedoEnabled(undoState)
示例3: initializeFormats
# 需要导入模块: from PyQt5.Qt import QTextCharFormat [as 别名]
# 或者: from PyQt5.Qt.QTextCharFormat import setFontPointSize [as 别名]
def initializeFormats(cls):
if cls.Formats:
return
baseFormat = QTextCharFormat()
baseFormat.setFontFamily('monospace')
baseFormat.setFontPointSize(11)
for name, color, bold, italic in (
("normal", "#000000", False, False),
("keyword", "#000080", True, False),
("builtin", "#0000A0", False, False),
("constant", "#0000C0", False, False),
("decorator", "#0000E0", False, False),
("comment", "#007F00", False, True),
("string", "#808000", False, False),
("number", "#924900", False, False),
("error", "#FF0000", False, False),
("pyqt", "#50621A", False, False)):
format = QTextCharFormat(baseFormat)
format.setForeground(QColor(color))
if bold:
format.setFontWeight(QFont.Bold)
format.setFontItalic(italic)
cls.Formats[name] = format