本文整理汇总了Python中PyQt5.QtGui.QTextCursor.atEnd方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCursor.atEnd方法的具体用法?Python QTextCursor.atEnd怎么用?Python QTextCursor.atEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QTextCursor
的用法示例。
在下文中一共展示了QTextCursor.atEnd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lineNumberAreaPaintEvent
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import atEnd [as 别名]
def lineNumberAreaPaintEvent(self, event):
painter = QPainter(self.lineNumberArea)
painter.fillRect(event.rect(), colorValues['lineNumberArea'])
cursor = QTextCursor(self.document())
cursor.movePosition(QTextCursor.Start)
atEnd = False
while not atEnd:
rect = self.cursorRect(cursor)
block = cursor.block()
if block.isVisible():
number = str(cursor.blockNumber() + 1)
painter.setPen(colorValues['lineNumberAreaText'])
painter.drawText(0, rect.top(), self.lineNumberArea.width()-2,
self.fontMetrics().height(), Qt.AlignRight, number)
cursor.movePosition(QTextCursor.EndOfBlock)
atEnd = cursor.atEnd()
if not atEnd:
cursor.movePosition(QTextCursor.NextBlock)
示例2: paintEvent
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import atEnd [as 别名]
def paintEvent(self, event):
if not globalSettings.lineNumbersEnabled:
return QWidget.paintEvent(self, event)
painter = QPainter(self)
painter.fillRect(event.rect(), colorValues['lineNumberArea'])
cursor = QTextCursor(self.editor.document())
cursor.movePosition(QTextCursor.Start)
atEnd = False
if globalSettings.relativeLineNumbers:
relativeTo = self.editor.textCursor().blockNumber()
else:
relativeTo = -1
while not atEnd:
rect = self.editor.cursorRect(cursor)
block = cursor.block()
if block.isVisible():
number = str(cursor.blockNumber() - relativeTo).replace('-', '−')
painter.setPen(colorValues['lineNumberAreaText'])
painter.drawText(0, rect.top(), self.width() - 2,
self.fontMetrics().height(), Qt.AlignRight, number)
cursor.movePosition(QTextCursor.EndOfBlock)
atEnd = cursor.atEnd()
if not atEnd:
cursor.movePosition(QTextCursor.NextBlock)