本文整理汇总了Python中PyQt5.Qt.QFontInfo.family方法的典型用法代码示例。如果您正苦于以下问题:Python QFontInfo.family方法的具体用法?Python QFontInfo.family怎么用?Python QFontInfo.family使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QFontInfo
的用法示例。
在下文中一共展示了QFontInfo.family方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_data
# 需要导入模块: from PyQt5.Qt import QFontInfo [as 别名]
# 或者: from PyQt5.Qt.QFontInfo import family [as 别名]
def show_data(self, html):
def color_to_string(col):
ans = '#000000'
if col.isValid():
col = col.toRgb()
if col.isValid():
ans = unicode_type(col.name())
return ans
fi = QFontInfo(QApplication.font(self.parent()))
f = fi.pixelSize()+1+int(tweaks['change_book_details_font_size_by'])
fam = unicode_type(fi.family()).strip().replace('"', '')
if not fam:
fam = 'sans-serif'
c = color_to_string(QApplication.palette().color(QPalette.Normal,
QPalette.WindowText))
templ = '''\
<html>
<head>
<style type="text/css">
body, td {background-color: transparent; font-family: "%s"; font-size: %dpx; color: %s }
a { text-decoration: none; color: blue }
div.description { margin-top: 0; padding-top: 0; text-indent: 0 }
table { margin-bottom: 0; padding-bottom: 0; }
</style>
</head>
<body>
<div class="description">
%%s
</div>
</body>
<html>
'''%(fam, f, c)
self.setHtml(templ%html)
示例2: update_font_display
# 需要导入模块: from PyQt5.Qt import QFontInfo [as 别名]
# 或者: from PyQt5.Qt.QFontInfo import family [as 别名]
def update_font_display(self):
font = self.build_font_obj()
fi = QFontInfo(font)
name = unicode_type(fi.family())
self.font_display.setFont(font)
self.font_display.setText(name + ' [%dpt]'%fi.pointSize())
示例3: render_html
# 需要导入模块: from PyQt5.Qt import QFontInfo [as 别名]
# 或者: from PyQt5.Qt.QFontInfo import family [as 别名]
def render_html(mi, css, vertical, widget, all_fields=False, render_data_func=None): # {{{
table, comment_fields = (render_data_func or render_data)(
mi, all_fields=all_fields, use_roman_numbers=config["use_roman_numerals_for_series_number"]
)
def color_to_string(col):
ans = "#000000"
if col.isValid():
col = col.toRgb()
if col.isValid():
ans = unicode(col.name())
return ans
fi = QFontInfo(QApplication.font(widget))
f = fi.pixelSize() + 1 + int(tweaks["change_book_details_font_size_by"])
fam = unicode(fi.family()).strip().replace('"', "")
if not fam:
fam = "sans-serif"
c = color_to_string(QApplication.palette().color(QPalette.Normal, QPalette.WindowText))
templ = u"""\
<html>
<head>
<style type="text/css">
body, td {
background-color: transparent;
font-size: %dpx;
font-family: "%s",sans-serif;
color: %s
}
</style>
<style type="text/css">
%s
</style>
</head>
<body>
%%s
</body>
<html>
""" % (
f,
fam,
c,
css,
)
comments = u""
if comment_fields:
comments = "\n".join(u"<div>%s</div>" % x for x in comment_fields)
right_pane = u'<div id="comments" class="comments">%s</div>' % comments
if vertical:
ans = templ % (table + right_pane)
else:
ans = templ % (
u'<table><tr><td valign="top" '
'style="padding-right:2em; width:40%%">%s</td><td valign="top">%s</td></tr></table>' % (table, right_pane)
)
return ans
示例4: change_font
# 需要导入模块: from PyQt5.Qt import QFontInfo [as 别名]
# 或者: from PyQt5.Qt.QFontInfo import family [as 别名]
def change_font(self, *args):
fd = QFontDialog(self.build_font_obj(), self)
if fd.exec_() == fd.Accepted:
font = fd.selectedFont()
fi = QFontInfo(font)
self.current_font = [unicode(fi.family()), fi.pointSize(),
fi.weight(), fi.italic(), font.stretch()]
self.update_font_display()
self.changed_signal.emit()
示例5: set_font_style
# 需要导入模块: from PyQt5.Qt import QFontInfo [as 别名]
# 或者: from PyQt5.Qt.QFontInfo import family [as 别名]
def set_font_style(self):
fi = QFontInfo(QApplication.font(self))
f = fi.pixelSize() + 1 + int(tweaks['change_book_details_font_size_by'])
fam = unicode(fi.family()).strip().replace('"', '')
if not fam:
fam = 'sans-serif'
style = 'font-size: %fpx; font-family:"%s",sans-serif;' % (f, fam)
# toList() is needed because PyQt on Debian is old/broken
for body in self.page().mainFrame().documentElement().findAll('body').toList():
body.setAttribute('style', style)
self.page().setContentEditable(not self.readonly)
示例6: render_html
# 需要导入模块: from PyQt5.Qt import QFontInfo [as 别名]
# 或者: from PyQt5.Qt.QFontInfo import family [as 别名]
def render_html(mi, css, vertical, widget, all_fields=False, render_data_func=None, pref_name='book_display_fields'): # {{{
func = render_data_func or render_data
try:
table, comment_fields = func(mi, all_fields=all_fields,
use_roman_numbers=config['use_roman_numerals_for_series_number'], pref_name=pref_name)
except TypeError:
table, comment_fields = func(mi, all_fields=all_fields,
use_roman_numbers=config['use_roman_numerals_for_series_number'])
def color_to_string(col):
ans = '#000000'
if col.isValid():
col = col.toRgb()
if col.isValid():
ans = unicode(col.name())
return ans
fi = QFontInfo(QApplication.font(widget))
f = fi.pixelSize() + 1 + int(tweaks['change_book_details_font_size_by'])
fam = unicode(fi.family()).strip().replace('"', '')
if not fam:
fam = 'sans-serif'
c = color_to_string(QApplication.palette().color(QPalette.Normal,
QPalette.WindowText))
templ = u'''\
<html>
<head>
<style type="text/css">
body, td {
background-color: transparent;
font-size: %dpx;
font-family: "%s",sans-serif;
color: %s
}
</style>
<style type="text/css">
%s
</style>
</head>
<body>
%%s
</body>
<html>
'''%(f, fam, c, css)
comments = u''
if comment_fields:
comments = '\n'.join(u'<div>%s</div>' % x for x in comment_fields)
right_pane = u'<div id="comments" class="comments">%s</div>'%comments
if vertical:
ans = templ%(table+right_pane)
else:
if gprefs['book_details_narrow_comments_layout'] == 'columns':
ans = templ%(u'<table><tr><td valign="top" '
'style="padding-right:2em; width:40%%">%s</td><td valign="top">%s</td></tr></table>'
% (table, right_pane))
else:
ans = templ%(u'<div style="float: left; margin-right: 1em; margin-bottom: 1em; max-width: 40%">{}</div><div>{}</div>'.format(
table, right_pane))
return ans