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


Python QTextCursor.positionInBlock方法代码示例

本文整理汇总了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)
开发者ID:tallforasmurf,项目名称:PPQT2,代码行数:29,代码来源:editview.py

示例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)
开发者ID:B-Rich,项目名称:PPQT2,代码行数:25,代码来源:editview.py


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