• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python metainfo.info函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中metainfo.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: pixmap

def pixmap(cursor, num_lines=6, scale=0.8):
    """Return a QPixmap displaying the selected lines of the document.

    If the cursor has no selection, num_lines are drawn.

    By default the text is drawn 0.8 * the normal font size. You can change
    that by supplying the scale parameter.

    """
    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() * scale)
    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))
    return pix
开发者ID:19joho66,项目名称:frescobaldi,代码行数:30,代码来源:documenttooltip.py


示例2: show

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,代码行数:35,代码来源:documenttooltip.py


示例3: updateDocActions

 def updateDocActions(self, doc):
     minfo = metainfo.info(doc)
     if minfo.highlighting:
         highlighter.highlighter(doc)
     ac = self.actionCollection
     ac.view_highlighting.setChecked(minfo.highlighting)
     ac.tools_indent_auto.setChecked(minfo.auto_indent)
开发者ID:m0003r,项目名称:frescobaldi,代码行数:7,代码来源:documentactions.py


示例4: edit

 def edit(self, cursor):
     """Edit the block at the specified QTextCursor."""
     if self._document:
         self._document.closed.disconnect(self.reject)
     self._document = cursor.document()
     self._document.closed.connect(self.reject)
     
     # don't change the cursor
     c = self._range = QTextCursor(cursor)
     cursorpos = c.position() - c.block().position()
     cursortools.strip_indent(c)
     indentpos = c.position() - c.block().position()
     c.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor)
     self.view.setPlainText(c.selection().toPlainText())
     
     self.highlighter.setInitialState(tokeniter.state(cursortools.block(cursor)))
     self.highlighter.setHighlighting(metainfo.info(cursor.document()).highlighting)
     self.highlighter.rehighlight()
     
     # let autocomplete query the real document as if we're at the start
     # of the current block
     self.completer.document_cursor = QTextCursor(cursor.block())
     self.completer.autoComplete = QSettings().value("autocomplete", True, bool)
     
     cursor = self.view.textCursor()
     cursor.setPosition(max(0, cursorpos-indentpos))
     self.view.setTextCursor(cursor)
     
     self.updateMessage()
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:29,代码来源:editinplace.py


示例5: cut_assign

def cut_assign(cursor):
    """Cuts selected text and assigns it to a LilyPond variable."""
    # ask the variable name
    name = inputdialog.getText(None, _("Cut and Assign"), _(
        "Please enter the name for the variable to assign the selected "
        "text to:"), regexp="[A-Za-z]+")
    if not name:
        return
    
    cursortools.strip_selection(cursor)
    
    # determine state at cursor
    block = cursortools.block(cursor)
    state = tokeniter.state(block)
    for t in tokeniter.partition(cursor).left:
        state.follow(t)
    
    mode = ""
    for p in state.parsers():
        if isinstance(p, ly.lex.lilypond.ParseInputMode):
            if isinstance(p, ly.lex.lilypond.ParseLyricMode):
                mode = " \\lyricmode"
            elif isinstance(p, ly.lex.lilypond.ParseChordMode):
                mode = " \\chordmode"
            elif isinstance(p, ly.lex.lilypond.ParseFigureMode):
                mode = " \\figuremode"
            elif isinstance(p, ly.lex.lilypond.ParseDrumMode):
                mode = " \\drummode"
            break

    # find insertion place:
    found = False
    while block.previous().isValid():
        block = block.previous()
        state = tokeniter.state(block)
        if isinstance(state.parser(), ly.lex.lilypond.ParseGlobal):
            found = True
            break
        tokens = tokeniter.tokens(block)
        for t in tokens:
            if isinstance(t, ly.lex.lilypond.Name):
                found = True
                break
            elif not isinstance(t, (ly.lex.Space, ly.lex.Comment)):
                break
        if found:
            break
    insert = QTextCursor(block)
    text = cursor.selection().toPlainText()
    space = '\n' if '\n' in text else ' '
    text = ''.join((name, ' =', mode, ' {', space, text, space, '}\n\n'))
    with cursortools.compress_undo(cursor):
        cursor.insertText('\\' + name)
        pos = insert.selectionStart()
        insert.insertText(text)
    if metainfo.info(cursor.document()).auto_indent:
        insert.setPosition(pos, QTextCursor.KeepAnchor)
        with cursortools.compress_undo(insert, True):
            indent.re_indent(insert)
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:59,代码来源:cut_assign.py


示例6: __init__

 def __init__(self, document):
     QSyntaxHighlighter.__init__(self, document)
     self._fridge = ly.lex.Fridge()
     app.settingsChanged.connect(self.rehighlight)
     self._highlighting = metainfo.info(document).highlighting
     document.loaded.connect(self._resetHighlighting)
     self._mode = documentinfo.mode(document, False)
     variables.manager(document).changed.connect(self._variablesChange)
开发者ID:mbsrz1972,项目名称:frescobaldi,代码行数:8,代码来源:highlighter.py


示例7: htmlCopy

def htmlCopy(document, type='editor'):
    """Return a new QTextDocument with highlighting set as HTML textcharformats."""
    data = textformats.formatData(type)
    doc = QTextDocument()
    doc.setDefaultFont(data.font)
    doc.setPlainText(document.toPlainText())
    if metainfo.info(document).highlighting:
        highlight(doc, HighlightFormats(data), ly.lex.state(documentinfo.mode(document)))
    return doc
开发者ID:satoshi-porin,项目名称:frescobaldi,代码行数:9,代码来源:highlighter.py


示例8: showProgress

 def showProgress(self, document):
     job = jobmanager.job(document)
     if job and job.isRunning():
         buildtime = metainfo.info(document).buildtime
         if not buildtime:
             buildtime = 3.0 + document.blockCount() / 20 # very arbitrary estimate...
         self._bar.start(buildtime, job.elapsed())
     else:
         self._bar.stop(False)
开发者ID:WedgeLeft,项目名称:frescobaldi,代码行数:9,代码来源:progress.py


示例9: save

 def save(self):
     """Saves the marks to the metainfo."""
     d = {}
     for type in types:
         d[type] = lines = []
         for mark in self._marks[type]:
             linenum = mark.blockNumber()
             if linenum not in lines:
                 lines.append(linenum)
     metainfo.info(self.document()).bookmarks = json.dumps(d)
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:10,代码来源:bookmarks.py


示例10: load

 def load(self):
     """Loads the marks from the metainfo."""
     self._marks = dict((type, []) for type in types)
     marks = metainfo.info(self.document()).bookmarks
     try:
         d = json.loads(marks) or {}
     except ValueError:
         return # No JSON object could be decoded
     for type in types:
         self._marks[type] = [QTextCursor(self.document().findBlockByNumber(num)) for num in d.get(type, [])]
     self.marksChanged()
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:11,代码来源:bookmarks.py


示例11: keyPressEvent

 def keyPressEvent(self, ev):
     super(View, self).keyPressEvent(ev)
     
     if metainfo.info(self.document()).auto_indent:
         # run the indenter on Return or when the user entered a dedent token.
         import indent
         cursor = self.textCursor()
         if ev.text() == '\r' or (ev.text() in ('}', '#', '>') and indent.indentable(cursor)):
             indent.auto_indent_block(cursor.block())
             # fix subsequent vertical moves
             cursor.setPosition(cursor.position())
             self.setTextCursor(cursor)
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:12,代码来源:view.py


示例12: initializeDocument

 def initializeDocument(self):
     """This method is always called by the __init__ method.
     
     The default implementation does nothing for generic QTextDocuments,
     but for document.Document instances it connects to some additional
     signals to keep the mode up-to-date (reading it from the variables if
     needed) and initializes whether to enable visual highlighting from the
     document's metainfo.
     
     """
     document = self.document()
     if hasattr(document, "url"):
         self._highlighting = metainfo.info(document).highlighting
         document.loaded.connect(self._resetHighlighting)
         self._mode = documentinfo.mode(document, False)
         variables.manager(document).changed.connect(self._variablesChange)
开发者ID:brownian,项目名称:frescobaldi,代码行数:16,代码来源:highlighter.py


示例13: showProgress

 def showProgress(self, document):
     job = jobmanager.job(document)
     if job and job.is_running():
         buildtime = metainfo.info(document).buildtime
         if not buildtime:
             buildtime = 3.0 + document.blockCount() / 20 # very arbitrary estimate...
         self._bar.start(buildtime, job.elapsed_time())
         if jobattributes.get(job).hidden:
             self._bar.setEnabled(False)
             self._bar.setMaximumHeight(8)
             self._bar.setTextVisible(False)
         else:
             self._bar.setEnabled(True)
             self._bar.setMaximumHeight(14)
             self._bar.setTextVisible(True)
     else:
         self._bar.stop(False)
开发者ID:brownian,项目名称:frescobaldi,代码行数:17,代码来源:progress.py


示例14: html_copy

def html_copy(cursor, scheme="editor", number_lines=False):
    """Return a new QTextDocument with highlighting set as HTML textcharformats.
    
    The cursor is a cursor of a document.Document instance. If the cursor 
    has a selection, only the selection is put in the new document.
    
    If number_lines is True, line numbers are added.
    
    """
    data = textformats.formatData(scheme)
    doc = QTextDocument()
    doc.setDefaultFont(data.font)
    doc.setPlainText(cursor.document().toPlainText())
    if metainfo.info(cursor.document()).highlighting:
        highlight(doc, mapping(data), ly.lex.state(documentinfo.mode(cursor.document())))
    if cursor.hasSelection():
        # cut out not selected text
        start, end = cursor.selectionStart(), cursor.selectionEnd()
        cur1 = QTextCursor(doc)
        cur1.setPosition(start, QTextCursor.KeepAnchor)
        cur2 = QTextCursor(doc)
        cur2.setPosition(end)
        cur2.movePosition(QTextCursor.End, QTextCursor.KeepAnchor)
        cur2.removeSelectedText()
        cur1.removeSelectedText()
    if number_lines:
        c = QTextCursor(doc)
        f = QTextCharFormat()
        f.setBackground(QColor("#eeeeee"))
        if cursor.hasSelection():
            num = cursor.document().findBlock(cursor.selectionStart()).blockNumber() + 1
            last = cursor.document().findBlock(cursor.selectionEnd())
        else:
            num = 1
            last = cursor.document().lastBlock()
        lastnum = last.blockNumber() + 1
        padding = len(format(lastnum))
        block = doc.firstBlock()
        while block.isValid():
            c.setPosition(block.position())
            c.setCharFormat(f)
            c.insertText("{0:>{1}d} ".format(num, padding))
            block = block.next()
            num += 1
    return doc
开发者ID:brownian,项目名称:frescobaldi,代码行数:45,代码来源:highlighter.py


示例15: keyPressEvent

    def keyPressEvent(self, ev):
        """Reimplemented to perform actions after a key has been pressed.

        Currently handles:

        - indent change on Enter, }, # or >

        """
        super(View, self).keyPressEvent(ev)

        if metainfo.info(self.document()).auto_indent:
            # run the indenter on Return or when the user entered a dedent token.
            import indent
            cursor = self.textCursor()
            if ev.text() == '\r' or (ev.text() in ('}', '#', '>') and indent.indentable(cursor)):
                indent.auto_indent_block(cursor.block())
                # fix subsequent vertical moves
                cursor.setPosition(cursor.position())
                self.setTextCursor(cursor)
开发者ID:oleastre,项目名称:frescobaldi,代码行数:19,代码来源:view.py


示例16: keyPressEvent

    def keyPressEvent(self, ev):
        """Reimplemented to perform actions after a key has been pressed.

        Currently handles:

        - indent change on Enter, }, # or >
        
        - update the tooltip info when Ctrl is pressed

        """
        super(View, self).keyPressEvent(ev)
        if ev.key() == Qt.Key_Control and self.include_target:
            self.viewport().setCursor(Qt.PointingHandCursor)
        if metainfo.info(self.document()).auto_indent:
            # run the indenter on Return or when the user entered a dedent token.
            import indent
            cursor = self.textCursor()
            if ev.text() == '\r' or (ev.text() in ('}', '#', '>') and indent.indentable(cursor)):
                indent.auto_indent_block(cursor.block())
                # fix subsequent vertical moves
                cursor.setPosition(cursor.position())
                self.setTextCursor(cursor)
开发者ID:19joho66,项目名称:frescobaldi,代码行数:22,代码来源:view.py


示例17: storeCursor

 def storeCursor(self):
     """Stores our cursor position in the metainfo."""
     metainfo.info(self.document()).position = self.textCursor().position()
开发者ID:arnaldorusso,项目名称:frescobaldi,代码行数:3,代码来源:view.py


示例18: toggleHighlighting

 def toggleHighlighting(self):
     doc = self.currentDocument()
     minfo = metainfo.info(doc)
     minfo.highlighting = not minfo.highlighting
     highlighter.highlighter(doc).setHighlighting(minfo.highlighting)
     self.updateOtherDocActions()
开发者ID:m0003r,项目名称:frescobaldi,代码行数:6,代码来源:documentactions.py


示例19: restoreCursor

 def restoreCursor(self):
     """Places the cursor on the position saved in metainfo."""
     cursor = QTextCursor(self.document())
     cursor.setPosition(metainfo.info(self.document()).position)
     self.setTextCursor(cursor)
     QTimer.singleShot(0, self.ensureCursorVisible)
开发者ID:arnaldorusso,项目名称:frescobaldi,代码行数:6,代码来源:view.py


示例20: jobFinished

 def jobFinished(self, document, job, success):
     if document == self.viewSpace().document():
         self._bar.stop(success)
         if success:
             metainfo.info(document).buildtime = job.elapsed()
开发者ID:WedgeLeft,项目名称:frescobaldi,代码行数:5,代码来源:progress.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_kernel函数代码示例发布时间:2022-05-27
下一篇:
Python api.insert_run_start函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap