本文整理汇总了Python中PyQt5.QtGui.QTextCursor.positionInBlock方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCursor.positionInBlock方法的具体用法?Python QTextCursor.positionInBlock怎么用?Python QTextCursor.positionInBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QTextCursor
的用法示例。
在下文中一共展示了QTextCursor.positionInBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _cursor_moved
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import positionInBlock [as 别名]
def _cursor_moved(self):
tc = QTextCursor(self.Editor.textCursor()) # copy of cursor
self.ColNumber.setText( str( tc.positionInBlock() ) )
tb = tc.block()
if tb == self.last_text_block :
return # still on same line, nothing more to do
# Fill in line-number widget, line #s are origin-1
self.LineNumber.setText( str( tb.blockNumber()+1 ) )
# Fill in the image name and folio widgets
pn = self.page_model.page_index(tc.position())
if pn is not None : # the page model has info on this position
self.ImageFilename.setText(self.page_model.filename(pn))
self.Folio.setText(self.page_model.folio_string(pn))
else: # no image data, or cursor is above page 1
self.ImageFilename.setText('')
self.Folio.setText('')
# Change the current-line "extra selection" to the new current line.
# Note: the cursor member of the extra selection may not have a
# selection. If it does, the current line highlight disappears. The
# cursor "tc" may or may not have a selection; to make sure, we clone
# it and remove any selection from it.
cltc = QTextCursor(tc)
cltc.setPosition(tc.position(),QTextCursor.MoveAnchor)
# Set the cloned cursor into the current line extra selection object.
self.current_line_sel.cursor = cltc
# Re-assign the list of extra selections to force update of display.
self.Editor.setExtraSelections(self.extra_sel_list)
示例2: _cursor_moved
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import positionInBlock [as 别名]
def _cursor_moved(self):
tc = QTextCursor(self.Editor.textCursor()) # copy of cursor
self.ColNumber.setText( str( tc.positionInBlock() ) )
tb = tc.block()
if tb == self.last_text_block :
return # still on same line, nothing more to do
# Fill in line-number widget, line #s are origin-1
self.LineNumber.setText( str( tb.blockNumber()+1 ) )
# Fill in the image name and folio widgets
pn = self.page_model.page_index(tc.position())
if pn is not None : # the page model has info on this position
self.ImageFilename.setText(self.page_model.filename(pn))
self.Folio.setText(self.page_model.folio_string(pn))
else: # no image data, or cursor is above page 1
self.ImageFilename.setText('')
self.Folio.setText('')
# Change the extra selection to the current line. The cursor needs
# to have no selection. Yes, we are here because the cursor moved,
# but that doesn't mean no-selection; it might have moved because
# of a shift-click extending the selection.
#xtc.clearSelection()
self.current_line_sel.cursor = tc
self.Editor.setExtraSelections(self.extra_sel_list)