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


Python QTextEdit.insertHtml方法代码示例

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


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

示例1: insertHtmlMessage

# 需要导入模块: from PyQt4.Qt import QTextEdit [as 别名]
# 或者: from PyQt4.Qt.QTextEdit import insertHtml [as 别名]
    def insertHtmlMessage(self, text, setAsDefault=True,
                          minLines=4, maxLines=10,
                          replace=True):
        """Insert <text> (HTML) into the message groupbox.
        <minLines> - The minimum number of lines (of text) to display in the TextEdit.
        if <minLines>=0 the TextEdit will fit its own height to fit <text>. The
        default height is 4 (lines of text).
        <maxLines> - The maximum number of lines to display in the TextEdit widget.
        <replace> should be set to False if you do not wish
        to replace the current text. It will append <text> instead.

        Shows the message groupbox if it is hidden.
        """
        if setAsDefault:
            self.defaultText = text
            self.setAsDefault = True

        if replace:
            self.MessageTextEdit.clear()

        if text:
            self._setHeight(minLines, maxLines)
            QTextEdit.insertHtml(self.MessageTextEdit, text)
            self.show()
        else:
            # Hide the message groupbox if it contains no text.
            self.hide()
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:29,代码来源:PropertyManagerMixin.py

示例2: insertHtml

# 需要导入模块: from PyQt4.Qt import QTextEdit [as 别名]
# 或者: from PyQt4.Qt.QTextEdit import insertHtml [as 别名]
    def insertHtml(self, 
                   text, 
                   setAsDefault = False, 
                   minLines     = 4, 
                   maxLines     = 6, 
                   replace      = True
                   ):
        """
        Insert <text> (HTML) into the Prop Mgr's message groupbox.
        <minLines> is the minimum number of lines to
        display, even if the text takes up fewer lines. The default
        number of lines is 4.
        <maxLines> is the maximum number of lines to
        diplay before adding a vertical scrollbar.
        <replace> should be set to False if you do not wish
        to replace the current text. It will append <text> instead.
        """
        if setAsDefault:
            self.defaultText = text
            self.setAsDefault = True
    
        if replace:
            # Replace the text by selecting effectively all text and
            # insert the new text 'over' it (overwrite). :jbirac: 20070629
            cursor  =  self.textCursor()
            cursor.setPosition( 0, 
                                QTextCursor.MoveAnchor )
            cursor.setPosition( len(self.toPlainText()), 
                                QTextCursor.KeepAnchor )
            self.setTextCursor( cursor )
        
        QTextEdit.insertHtml(self, text)

        if replace:
            # Restore the previous cursor position/selection and mode.
            cursor.setPosition( len(self.toPlainText()), 
                                QTextCursor.MoveAnchor )
            self.setTextCursor( cursor )
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:40,代码来源:PM_TextEdit.py


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