本文整理汇总了Python中PyQt4.QtGui.QFontMetricsF.averageCharWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QFontMetricsF.averageCharWidth方法的具体用法?Python QFontMetricsF.averageCharWidth怎么用?Python QFontMetricsF.averageCharWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QFontMetricsF
的用法示例。
在下文中一共展示了QFontMetricsF.averageCharWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update_margin_line
# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import averageCharWidth [as 别名]
def _update_margin_line(self, font):
# Fix for older version of Qt which doens't has ForceIntegerMetrics
if "ForceIntegerMetrics" in dir(QFont):
self.document().defaultFont().setStyleStrategy(
QFont.ForceIntegerMetrics)
font_metrics = QFontMetricsF(self.document().defaultFont())
if (font_metrics.width("#") * settings.MARGIN_LINE) == \
(font_metrics.width(" ") * settings.MARGIN_LINE):
self.pos_margin = font_metrics.width('#') * settings.MARGIN_LINE
else:
char_width = font_metrics.averageCharWidth()
self.pos_margin = char_width * settings.MARGIN_LINE
示例2: set_font
# 需要导入模块: from PyQt4.QtGui import QFontMetricsF [as 别名]
# 或者: from PyQt4.QtGui.QFontMetricsF import averageCharWidth [as 别名]
def set_font(self, family=settings.FONT_FAMILY, size=settings.FONT_SIZE):
font = QFont(family, size)
self.document().setDefaultFont(font)
# Fix for older version of Qt which doens't has ForceIntegerMetrics
if "ForceIntegerMetrics" in dir(QFont):
self.document().defaultFont().setStyleStrategy(
QFont.ForceIntegerMetrics)
font_metrics = QFontMetricsF(self.document().defaultFont())
if (font_metrics.width("#") * settings.MARGIN_LINE) == \
(font_metrics.width(" ") * settings.MARGIN_LINE):
self.pos_margin = font_metrics.width('#') * settings.MARGIN_LINE
else:
char_width = font_metrics.averageCharWidth()
self.pos_margin = char_width * settings.MARGIN_LINE