本文整理汇总了Python中qtpy.QtWidgets.QLabel.setTextFormat方法的典型用法代码示例。如果您正苦于以下问题:Python QLabel.setTextFormat方法的具体用法?Python QLabel.setTextFormat怎么用?Python QLabel.setTextFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QLabel
的用法示例。
在下文中一共展示了QLabel.setTextFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fix_size
# 需要导入模块: from qtpy.QtWidgets import QLabel [as 别名]
# 或者: from qtpy.QtWidgets.QLabel import setTextFormat [as 别名]
def fix_size(self, content, extra=50):
"""
Adjusts the width and height of the file switcher,
based on its content.
"""
# Update size of dialog based on longest shortened path
strings = []
if content:
for rich_text in content:
label = QLabel(rich_text)
label.setTextFormat(Qt.PlainText)
strings.append(label.text())
fm = label.fontMetrics()
# Max width
max_width = max([fm.width(s) * 1.3 for s in strings])
self.list.setMinimumWidth(max_width + extra)
# Max height
if len(strings) < 8:
max_entries = len(strings)
else:
max_entries = 8
max_height = fm.height() * max_entries * 2.5
self.list.setMinimumHeight(max_height)
# Set position according to size
self.set_dialog_position()
示例2: fix_size
# 需要导入模块: from qtpy.QtWidgets import QLabel [as 别名]
# 或者: from qtpy.QtWidgets.QLabel import setTextFormat [as 别名]
def fix_size(self, content, extra=50):
"""Adjusts the width of the file switcher, based on the content."""
# Update size of dialog based on longest shortened path
strings = []
if content:
for rich_text in content:
label = QLabel(rich_text)
label.setTextFormat(Qt.PlainText)
strings.append(label.text())
fm = label.fontMetrics()
max_width = max([fm.width(s)*1.3 for s in strings])
self.list.setMinimumWidth(max_width + extra)
self.set_dialog_position()
示例3: get_item_size
# 需要导入模块: from qtpy.QtWidgets import QLabel [as 别名]
# 或者: from qtpy.QtWidgets.QLabel import setTextFormat [as 别名]
def get_item_size(self, content):
"""
Get the max size (width and height) for the elements of a list of
strings as a QLabel.
"""
strings = []
if content:
for rich_text in content:
label = QLabel(rich_text)
label.setTextFormat(Qt.PlainText)
strings.append(label.text())
fm = label.fontMetrics()
return (max([fm.width(s) * 1.3 for s in strings]), fm.height())