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


Python Qt.mightBeRichText方法代码示例

本文整理汇总了Python中PyQt4.QtCore.Qt.mightBeRichText方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.mightBeRichText方法的具体用法?Python Qt.mightBeRichText怎么用?Python Qt.mightBeRichText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore.Qt的用法示例。


在下文中一共展示了Qt.mightBeRichText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getTooltipValue

# 需要导入模块: from PyQt4.QtCore import Qt [as 别名]
# 或者: from PyQt4.QtCore.Qt import mightBeRichText [as 别名]
def getTooltipValue( value ):
    """ Takes a potentially multilined string and converts it to
        the form suitable for tooltips """

    value = str( value )
    if Qt.mightBeRichText( value ):
        tooltipValue = str( Qt.escape( value ) )
    else:
        tooltipValue = value

    lines = tooltipValue.splitlines()
    lineCount = len( lines )
    if lineCount > 1:
        value = ""
        index = 0
        for line in lines:
            if index >= 5:  # First 5 lines only
                break
            if index > 0:
                value += "\n"
            if len( line ) > 128:
                value += line[ : 128 ] + "<...>"
            else:
                value += line
            index += 1
        if lineCount > 5:
            value += "\n<...>"
    elif lineCount == 1:
        if len( lines[ 0 ] ) > 128:
            value = lines[ 0 ][ : 128 ] + "<...>"
        else:
            value = lines[ 0 ]

    return value
开发者ID:eaglexmw,项目名称:codimension,代码行数:36,代码来源:variableitems.py

示例2: drawContents

# 需要导入模块: from PyQt4.QtCore import Qt [as 别名]
# 或者: from PyQt4.QtCore.Qt import mightBeRichText [as 别名]
    def drawContents(self, painter):
        """
        Reimplementation of drawContents to limit the drawing
        inside `textRext`.

        """
        painter.setPen(self.__color)
        painter.setFont(self.font())

        if self.__textRect:
            rect = self.__textRect
        else:
            rect = self.rect().adjusted(5, 5, -5, -5)
        if Qt.mightBeRichText(self.__message):
            doc = QTextDocument()
            doc.setHtml(self.__message)
            doc.setTextWidth(rect.width())
            cursor = QTextCursor(doc)
            cursor.select(QTextCursor.Document)
            fmt = QTextBlockFormat()
            fmt.setAlignment(self.__alignment)
            cursor.mergeBlockFormat(fmt)
            painter.save()
            painter.translate(rect.topLeft())
            doc.drawContents(painter)
            painter.restore()
        else:
            painter.drawText(rect, self.__alignment, self.__message)
开发者ID:675801717,项目名称:orange3,代码行数:30,代码来源:splashscreen.py


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