本文整理汇总了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)