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


Python QTextCursor.clearSelection方法代码示例

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


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

示例1: focus_line

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import clearSelection [as 别名]
 def focus_line(self, line_no):
     """ highlight the line"""
     line_no -= 1
     cursor = QTextCursor(self.document().findBlockByLineNumber(line_no))
     cursor.clearSelection()
     highlight = QTextEdit.ExtraSelection()
     highlight.cursor = cursor
     highlight.format.setProperty(QTextFormat.FullWidthSelection, True)
     highlight.format.setBackground(QBrush(QColor("#657b83")))
     self.setExtraSelections([highlight])
     self.setTextCursor(cursor)
开发者ID:c0deforfun,项目名称:LLL,代码行数:13,代码来源:__init__.py

示例2: write

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import clearSelection [as 别名]
 def write(self, s):
     if self.echo:
         sys.__stdout__.write(s)
     doc = self.document()
     cursor = QTextCursor(doc)
     cursor.clearSelection()
     cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)
     cursor.insertText(s)
     cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)
     cursor.clearSelection()
     self.ensureCursorVisible()
     qApp.processEvents()
开发者ID:Fahad-Alsaidi,项目名称:scribus-svn,代码行数:14,代码来源:console.py

示例3: __highlight

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import clearSelection [as 别名]
 def __highlight(self, positions, color=None, cancel=False):
     cursor =  QTextCursor(self.document())
     modified = self.document().isModified()
     for position in positions:
         if position > self.get_position('eof'):
             return
         cursor.setPosition(position)
         cursor.movePosition( QTextCursor.NextCharacter,
                              QTextCursor.KeepAnchor)
         charformat = cursor.charFormat()
         pen =  QPen(Qt.NoPen) if cancel else  QPen(color)
         charformat.setTextOutline(pen)
         cursor.setCharFormat(charformat)
     if cancel:
         charformat =  QTextCharFormat()
         cursor.movePosition( QTextCursor.NextCharacter,
                              QTextCursor.KeepAnchor)
         cursor.setCharFormat(charformat)
         cursor.clearSelection()
         self.setCurrentCharFormat(charformat)
     self.document().setModified(modified)
开发者ID:khertan,项目名称:KhtEditor,代码行数:23,代码来源:editor.py

示例4: __duplicate_line_or_selection

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import clearSelection [as 别名]
 def __duplicate_line_or_selection(self, after_current_line=True):
     """Duplicate current line or selected text"""
     cursor = self.textCursor()
     cursor.beginEditBlock()
     start_pos, end_pos = self.__save_selection()
     if to_text_string(cursor.selectedText()):
         cursor.setPosition(end_pos)
         # Check if end_pos is at the start of a block: if so, starting
         # changes from the previous block
         cursor.movePosition(QTextCursor.StartOfBlock,
                             QTextCursor.KeepAnchor)
         if not to_text_string(cursor.selectedText()):
             cursor.movePosition(QTextCursor.PreviousBlock)
             end_pos = cursor.position()
         
     cursor.setPosition(start_pos)
     cursor.movePosition(QTextCursor.StartOfBlock)
     while cursor.position() <= end_pos:
         cursor.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor)
         if cursor.atEnd():
             cursor_temp = QTextCursor(cursor)
             cursor_temp.clearSelection()
             cursor_temp.insertText(self.get_line_separator())
             break
         cursor.movePosition(QTextCursor.NextBlock, QTextCursor.KeepAnchor)            
     text = cursor.selectedText()
     cursor.clearSelection()
     
     if not after_current_line:
         # Moving cursor before current line/selected text
         cursor.setPosition(start_pos)
         cursor.movePosition(QTextCursor.StartOfBlock)
         start_pos += len(text)
         end_pos += len(text)
     
     cursor.insertText(text)
     cursor.endEditBlock()
     self.setTextCursor(cursor)
     self.__restore_selection(start_pos, end_pos)
开发者ID:koll00,项目名称:Gui_SM,代码行数:41,代码来源:base.py


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