当前位置: 首页>>代码示例>>Python>>正文


Python QLabel.setTextFormat方法代码示例

本文整理汇总了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()
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:30,代码来源:fileswitcher.py

示例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()
开发者ID:JamesLTaylor,项目名称:spyder,代码行数:15,代码来源:fileswitcher.py

示例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())
开发者ID:rlaverde,项目名称:spyder,代码行数:16,代码来源:fileswitcher.py


注:本文中的qtpy.QtWidgets.QLabel.setTextFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。