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


Python QTextCursor.movePosition方法代码示例

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


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

示例1: onMatchNumberChange

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
    def onMatchNumberChange(self, matchNumber):
        # Set default format on the whole text before highlighting the selected
        # match.
        document = self.matchText.document()
        cursor = QTextCursor(document)
        cursor.movePosition(QTextCursor.End, QTextCursor.KeepAnchor)
        cursor.setCharFormat(QTextCharFormat())

        search = self.getSearchText()
        for i, match in enumerate(self.regex.finditer(search)):
            if i + 1 == matchNumber:
                break
        else:
            assert False, ("We didn't find a match?! (RE=%r, text=%r" %
                           (self.regex.pattern, search))

        self.formatMatchedText(document, match)

        model = self.groupsView.model()
        model.clear()

        # Create a reversed self.regex.groupindex dictionnary
        groupsIndexes = dict((v, k)
                             for (k, v) in self.regex.groupindex.iteritems())

        for i in range(1, self.regex.groups + 1):
            groupName = groupsIndexes.get(i, "")
            groupValue = match.group(i)
            model.append((groupName, groupValue))
开发者ID:inactivist,项目名称:kodos-qt4,代码行数:31,代码来源:main.py

示例2: setLine

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
 def setLine(self, line):
     cursor = QTextCursor(self.document())
     cursor.movePosition(QTextCursor.End)
     cursor.setPosition(self.newPromptPos, QTextCursor.KeepAnchor)
     cursor.removeSelectedText()
     cursor.insertText(line)
     self.setTextCursor(cursor)
开发者ID:kernc,项目名称:Orange3-Spark,代码行数:9,代码来源:pyspark_script_console.py

示例3: show

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
def show(cursor, pos=None, num_lines=6):
    """Displays a tooltip showing part of the cursor's Document.
    
    If the cursor has a selection, those blocks are displayed.
    Otherwise, num_lines lines are displayed.
    
    If pos is not given, the global mouse position is used.
    
    """
    block = cursor.document().findBlock(cursor.selectionStart())
    c2 = QTextCursor(block)
    if cursor.hasSelection():
        c2.setPosition(cursor.selectionEnd(), QTextCursor.KeepAnchor)
        c2.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor)
    else:
        c2.movePosition(QTextCursor.NextBlock, QTextCursor.KeepAnchor, num_lines)
    
    data = textformats.formatData('editor')
    
    doc = QTextDocument()
    font = QFont(data.font)
    font.setPointSizeF(font.pointSizeF() * .8)
    doc.setDefaultFont(font)
    doc.setPlainText(c2.selection().toPlainText())
    if metainfo.info(cursor.document()).highlighting:
        highlighter.highlight(doc, state=tokeniter.state(block))
    size = doc.size().toSize() + QSize(8, -4)
    pix = QPixmap(size)
    pix.fill(data.baseColors['background'])
    doc.drawContents(QPainter(pix))
    label = QLabel()
    label.setPixmap(pix)
    label.setStyleSheet("QLabel { border: 1px solid #777; }")
    label.resize(size)
    widgets.customtooltip.show(label, pos)
开发者ID:WedgeLeft,项目名称:frescobaldi,代码行数:37,代码来源:documenttooltip.py

示例4: append

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
 def append(self, text):
     """Append line to the end
     """
     cursor = QTextCursor(self._doc)
     cursor.movePosition(QTextCursor.End)
     cursor.insertBlock()
     cursor.insertText(text)
开发者ID:amirgeva,项目名称:coide,代码行数:9,代码来源:lines.py

示例5: cursorAt

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
 def cursorAt(self, position, in_active_area=True):
     c = QTextCursor(self.block)
     p = min(position, self.length-1)
     if in_active_area:
         p = max(p, self.active_area_start)
     c.movePosition(QTextCursor.Right, QTextCursor.MoveAnchor, p)
     return c
开发者ID:jonathanverner,项目名称:qidle,代码行数:9,代码来源:textblock.py

示例6: _find

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
    def _find(self, textEdit=None, backward=False):
        if textEdit is None:
            textEdit = self.textEdit

        found = False

        if textEdit is not None:
            cursor = textEdit.textCursor()
            text, flags = self._textAndFindFlags(backward=backward)
            position = cursor.position()
            cursor = textEdit.document().find(text, cursor, flags)

            if not cursor.isNull():
                textEdit.setTextCursor(cursor)
                found = True
            elif self.wrapAroundCheckBox.isChecked():
                cursor = QTextCursor(textEdit.textCursor())
                cursor.movePosition(backward and QTextCursor.End or QTextCursor.Start)
                cursor = textEdit.document().find(text, cursor, flags)
                if not cursor.isNull():
                    if position == cursor.position():
                        pass #todo
                    textEdit.setTextCursor(cursor)
                    found = True
            self.writeSettings()

        if not found:
            QApplication.beep()
            self.feedbackLabel.setText(self.tr("Not found"))
        else:
            self.clearFeedback()
开发者ID:gt-ros-pkg,项目名称:rcommander-core,代码行数:33,代码来源:findreplace.py

示例7: _selectLines

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
 def _selectLines(self, startBlockNumber, endBlockNumber):
     """Select whole lines
     """
     startBlock = self.document().findBlockByNumber(startBlockNumber)
     endBlock = self.document().findBlockByNumber(endBlockNumber)
     cursor = QTextCursor(startBlock)
     cursor.setPosition(endBlock.position(), QTextCursor.KeepAnchor)
     cursor.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor)
     self.setTextCursor(cursor)
开发者ID:kcrossen,项目名称:qutepart,代码行数:11,代码来源:__init__.py

示例8: isBlankAfter

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
def isBlankAfter(cursor):
    """Returns True if there's no text on the current line after the cursor."""
    if cursor.hasSelection():
        return False
    if cursor.atBlockEnd():
        return True
    c = QTextCursor(cursor)
    c.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor)
    return c.selection().toPlainText().isspace()
开发者ID:mbsrz1972,项目名称:frescobaldi,代码行数:11,代码来源:cursortools.py

示例9: isBlankBefore

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
def isBlankBefore(cursor):
    """Returns True if there's no text on the current line before the cursor."""
    if cursor.hasSelection():
        return False
    if cursor.atBlockStart():
        return True
    c = QTextCursor(cursor)
    c.movePosition(QTextCursor.StartOfBlock, QTextCursor.KeepAnchor)
    return c.selection().toPlainText().isspace()
开发者ID:mbsrz1972,项目名称:frescobaldi,代码行数:11,代码来源:cursortools.py

示例10: show_msg

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
 def show_msg(self, message):
     """Show message in textBrowser
     """
     self.textEdit.append(message)
     # Scroll to end of the last message
     cursor = QTextCursor(self.textEdit.textCursor())
     cursor.movePosition(QTextCursor.End)
     self.textEdit.setTextCursor(cursor)
     QApplication.processEvents()
开发者ID:luis-wang,项目名称:python_Tesseract_GUI_Demo,代码行数:11,代码来源:pyTesseractDemo-bak.py

示例11: formatMatchedText

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
    def formatMatchedText(self, document, match):
        """Format the matched text in a document"""

        cursor = QTextCursor(document)
        cursor.setPosition(match.start())
        cursor.movePosition(
            QTextCursor.NextCharacter,
            QTextCursor.KeepAnchor,
            match.end() - match.start())
        cursor.setCharFormat(self.matchFormat)
开发者ID:inactivist,项目名称:kodos-qt4,代码行数:12,代码来源:main.py

示例12: add_debug_message

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
    def add_debug_message(self, message):
        self.text_debug.append(message)

        while self.text_debug.document().blockCount() > 1000:
            cursor = QTextCursor(self.text_debug.document().begin())
            cursor.select(QTextCursor.BlockUnderCursor)
            cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor)
            cursor.removeSelectedText()

        if self.checkbox_debug_auto_scroll.isChecked():
            self.text_debug.verticalScrollBar().setValue(self.text_debug.verticalScrollBar().maximum())
开发者ID:fscherwi,项目名称:brickv,代码行数:13,代码来源:setup_dialog.py

示例13: setTextCursor

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
 def setTextCursor(self, cursor):
     """Reimplemented to show n surrounding lines."""
     numlines = QSettings().value("view_preferences/context_lines", 3, int)
     if numlines > 0:
         c = QTextCursor(cursor)
         c.setPosition(cursor.selectionEnd())
         c.movePosition(QTextCursor.Down, QTextCursor.MoveAnchor, numlines)
         super(View, self).setTextCursor(c)
         c.setPosition(cursor.selectionStart())
         c.movePosition(QTextCursor.Up, QTextCursor.MoveAnchor, numlines)
         super(View, self).setTextCursor(c)
     super(View, self).setTextCursor(cursor)
开发者ID:brumleygap,项目名称:frescobaldi,代码行数:14,代码来源:view.py

示例14: __highlight

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [as 别名]
 def __highlight(self, positions, color=None, cancel=False):
     cursor = QTextCursor(self.document())
     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)
开发者ID:Brainsciences,项目名称:luminoso,代码行数:14,代码来源:qtebase.py

示例15: write

# 需要导入模块: from PyQt4.QtGui import QTextCursor [as 别名]
# 或者: from PyQt4.QtGui.QTextCursor import movePosition [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


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