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


Python QTextCursor.selection方法代码示例

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


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

示例1: show

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

示例2: isBlankAfter

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

示例3: isBlankBefore

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


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