當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。