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


Python QTextCharFormat.setAnchorHref方法代码示例

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


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

示例1: writeMessage

# 需要导入模块: from PyQt5.QtGui import QTextCharFormat [as 别名]
# 或者: from PyQt5.QtGui.QTextCharFormat import setAnchorHref [as 别名]
    def writeMessage(self, message, type):
        """This writes both status and output messages to the log.

        For output messages also the correct encoding is re-applied:
        LilyPond writes filenames out in the system's filesystemencoding,
        while the messages are always written in UTF-8 encoding...

        """
        if type == job.STDERR:
            # find filenames in message:
            parts = iter(errors.message_re.split(message.encode('latin1')))
            msg = next(parts).decode('utf-8', 'replace')
            self.cursor.insertText(msg, self.textFormat(type))
            enc = sys.getfilesystemencoding()

            for url, path, line, col, msg in zip(*itertools.repeat(parts, 5)):
                url = url.decode(enc)
                path = path.decode(enc)
                msg = msg.decode('utf-8', 'replace')
                if self._rawView:
                    fmt = QTextCharFormat(self.textFormat(type))
                    display_url = url
                else:
                    fmt = QTextCharFormat(self.textFormat("link"))
                    display_url = os.path.basename(path)
                fmt.setAnchor(True)
                fmt.setAnchorHref(str(len(self._errors)))
                fmt.setToolTip(_("Click to edit this file"))

                pos = self.cursor.position()
                self.cursor.insertText(display_url, fmt)
                self.cursor.insertText(msg, self.textFormat(type))
                self._errors.append((pos, self.cursor.position(), url))
        else:
            if type == job.STDOUT:
                # we use backslashreplace because LilyPond sometimes seems to write
                # incorrect utf-8 to standard output in \displayMusic, \displayScheme
                # functions etc.
                message = message.encode('latin1').decode('utf-8', 'backslashreplace')
            super(LogWidget, self).writeMessage(message, type)
开发者ID:brownian,项目名称:frescobaldi,代码行数:42,代码来源:logwidget.py


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