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


Python QApplication.clipboard方法代码示例

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


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

示例1: test_builtin_shift_del_and_ins

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
def test_builtin_shift_del_and_ins(editor_bot):
    """
    Test that the builtin key sequences Ctrl+Ins, Shit+Del and Shift+Ins result
    in copy, cut and paste actions in Windows and Linux.

    Regression test for issue #5035, #4947, and #5973.
    """
    editorstack, qtbot = editor_bot
    editor = editorstack.get_current_editor()
    QApplication.clipboard().clear()

    # Select the first line of the editor.
    qtbot.keyClick(editor, Qt.Key_End, modifier=Qt.ShiftModifier)
    assert editor.get_selected_text() == 'Line1'

    # Copy the selection with Ctrl+Ins.
    qtbot.keyClick(editor, Qt.Key_Insert, modifier=Qt.ControlModifier)
    assert QApplication.clipboard().text() == 'Line1'

    # Paste the copied text at the end of the line with Shift+Ins.
    qtbot.keyClick(editor, Qt.Key_End)
    qtbot.keyClick(editor, Qt.Key_Insert, modifier=Qt.ShiftModifier)
    assert editor.toPlainText() == 'Line1Line1\nLine2\nLine3\nLine4\n'

    # Select the second line in the editor again.
    qtbot.keyClick(editor, Qt.Key_Home, modifier=Qt.ShiftModifier)
    assert editor.get_selected_text() == 'Line1Line1'

    # Cut the selection with Shift+Del.
    qtbot.keyClick(editor, Qt.Key_Delete, modifier=Qt.ShiftModifier)
    assert QApplication.clipboard().text() == 'Line1Line1'
    assert editor.toPlainText() == '\nLine2\nLine3\nLine4\n'
开发者ID:burrbull,项目名称:spyder,代码行数:34,代码来源:test_shortcuts.py

示例2: copy

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
 def copy(self):
     """
     Reimplement Qt method
     Copy text to clipboard with correct EOL chars
     """
     if self.get_selected_text():
         QApplication.clipboard().setText(self.get_selected_text())
开发者ID:impact27,项目名称:spyder,代码行数:9,代码来源:base.py

示例3: test_copy_cut_paste_shortcuts

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
def test_copy_cut_paste_shortcuts(editor_bot):
    """
    Test that the copy, cut, and paste keyboard shortcuts are working as
    expected with the default Spyder keybindings.
    """
    editorstack, qtbot = editor_bot
    editor = editorstack.get_current_editor()
    QApplication.clipboard().clear()

    # Select and Copy the first line in the editor.
    qtbot.keyClick(editor, Qt.Key_End, modifier=Qt.ShiftModifier)
    assert editor.get_selected_text() == 'Line1'

    qtbot.keyClick(editor, Qt.Key_C, modifier=Qt.ControlModifier)
    assert QApplication.clipboard().text() == 'Line1'

    # Paste the selected text.
    qtbot.keyClick(editor, Qt.Key_Home)
    qtbot.keyClick(editor, Qt.Key_V, modifier=Qt.ControlModifier)
    assert editor.toPlainText() == 'Line1Line1\nLine2\nLine3\nLine4\n'

    # Select and Cut the first line in the editor.
    qtbot.keyClick(editor, Qt.Key_Home)
    qtbot.keyClick(editor, Qt.Key_End, modifier=Qt.ShiftModifier)
    assert editor.get_selected_text() == 'Line1Line1'

    qtbot.keyClick(editor, Qt.Key_X, modifier=Qt.ControlModifier)
    assert QApplication.clipboard().text() == 'Line1Line1'
    assert editor.toPlainText() == '\nLine2\nLine3\nLine4\n'
开发者ID:burrbull,项目名称:spyder,代码行数:31,代码来源:test_shortcuts.py

示例4: yDOLLAR

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
 def yDOLLAR(self, repeat):
     editor = self._widget.editor()
     cursor = editor.textCursor()
     cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor,
                         repeat)
     text = cursor.selectedText()
     QApplication.clipboard().setText(text)
开发者ID:Nodd,项目名称:spyder.vim,代码行数:9,代码来源:vim_widget.py

示例5: test_copy_to_clipboard

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
 def test_copy_to_clipboard(self):
     self.widget.loadFunction('name=LinearBackground,A0=0,A1=0')
     yield self.start_setup_menu()
     yield self.start_manage_setup()
     QApplication.clipboard().clear()
     self.trigger_action('action_CopyToClipboard')
     yield self.wait_for_true(lambda: QApplication.clipboard().text() != '')
     self.assertEqual(QApplication.clipboard().text(), 'name=LinearBackground,A0=0,A1=0')
开发者ID:mantidproject,项目名称:mantid,代码行数:10,代码来源:test_fitpropertybrowser.py

示例6: yw

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
 def yw(self, repeat):
     editor = self._widget.editor()
     cursor = editor.textCursor()
     cursor.movePosition(QTextCursor.NextWord, QTextCursor.KeepAnchor,
                         repeat - 1)
     cursor.movePosition(QTextCursor.EndOfWord, QTextCursor.KeepAnchor)
     text = cursor.selectedText()
     QApplication.clipboard().setText(text)
开发者ID:Nodd,项目名称:spyder.vim,代码行数:10,代码来源:vim_widget.py

示例7: copy_without_prompts

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
 def copy_without_prompts(self):
     """Copy text to clipboard without prompts"""
     text = self.get_selected_text()
     lines = text.split(os.linesep)
     for index, line in enumerate(lines):
         if line.startswith('>>> ') or line.startswith('... '):
             lines[index] = line[4:]
     text = os.linesep.join(lines)
     QApplication.clipboard().setText(text)
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:11,代码来源:shell.py

示例8: _submit_to_github

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
    def _submit_to_github(self):
        """Action to take when pressing the submit button."""
        # Get reference to the main window
        if self.parent() is not None:
            if getattr(self.parent(), 'main', False):
                # This covers the case when the dialog is attached
                # to the internal console
                main = self.parent().main
            else:
                # Else the dialog is attached to the main window
                # directly
                main = self.parent()
        else:
            main = None

        # Getting description and traceback
        title = self.title.text()
        description = self.input_description.toPlainText()
        traceback = self.error_traceback[:-1]  # Remove last EOL

        # Render issue
        if main is not None:
            issue_text = main.render_issue(description=description,
                                           traceback=traceback)
        else:
            issue_text = description

        try:
            if main is None:
                org = 'ccordoba12'
            else:
                org = 'spyder-ide'
            github_backend = GithubBackend(org, 'spyder', parent_widget=main)
            github_report = github_backend.send_report(title, issue_text)
            if github_report:
                self.close()
        except Exception:
            ret = QMessageBox.question(
                      self, _('Error'),
                      _("An error occurred while trying to send the issue to "
                        "Github automatically. Would you like to open it "
                        "manually?<br><br>"
                        "If so, please make sure to paste your clipboard "
                        "into the issue report box that will appear in a new "
                        "browser tab before clicking <i>Submit</i> on that "
                        "page."))
            if ret in [QMessageBox.Yes, QMessageBox.Ok]:
                QApplication.clipboard().setText(issue_text)
                issue_body = (
                    " \n<!---   *** BEFORE SUBMITTING: PASTE CLIPBOARD HERE "
                    "TO COMPLETE YOUR REPORT ***   ---!>\n")
                if main is not None:
                    main.report_issue(body=issue_body, title=title,
                                      open_webpage=True)
                else:
                    pass
开发者ID:impact27,项目名称:spyder,代码行数:58,代码来源:reporterror.py

示例9: copy_figure

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
    def copy_figure(self):
        """Copy figure to clipboard."""
        if self.fmt in ['image/png', 'image/jpeg']:
            qpixmap = QPixmap()
            qpixmap.loadFromData(self.fig, self.fmt.upper())
            QApplication.clipboard().setImage(qpixmap.toImage())
        elif self.fmt == 'image/svg+xml':
            svg_to_clipboard(self.fig)
        else:
            return

        self.blink_figure()
开发者ID:impact27,项目名称:spyder,代码行数:14,代码来源:figurebrowser.py

示例10: test_paste_from_clipboard

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
def test_paste_from_clipboard(self):
    assert (isinstance(self, TestFunctionBrowser))
    browser = self.widget
    browser.setFunction('name=FlatBackground;name=FlatBackground,A0=1')
    view = browser.view()
    user = BrowserUser(browser)

    QApplication.clipboard().setText('name=LinearBackground,A0=5,A1=10')
    pos = view.getVisualRectFunctionProperty('').center()
    tree = view.treeWidget().viewport()
    yield self.show_context_menu(tree, pos, pause=0)
    yield self.mouse_trigger_action('paste_from_clipboard', pause=0)
    fun = self.get_fit_function()
    self.assertEqual(fun.name, 'LinearBackground')
    self.assertEqual(user.structure_changed.call_count, 1)
开发者ID:mantidproject,项目名称:mantid,代码行数:17,代码来源:test_functionbrowser.py

示例11: closeEvent

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
 def closeEvent(self, *args, **kwargs):
     self.save_settings()
     # Enable paste of clipboard after termination
     clipboard = QApplication.clipboard()
     event = QEvent(QEvent.Clipboard)
     QApplication.sendEvent(clipboard, event)
     return QMainWindow.closeEvent(self, *args, **kwargs)
开发者ID:madsmpedersen,项目名称:MMPE,代码行数:9,代码来源:QtGuiLoader.py

示例12: copy

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
 def copy(self):
     """Copy text to clipboard"""
     if not self.selectedIndexes():
         return
     (row_min, row_max,
      col_min, col_max) = get_idx_rect(self.selectedIndexes())
     index = header = False
     if col_min == 0:
         col_min = 1
         index = True
     df = self.model().df
     if col_max == 0:  # To copy indices
         contents = '\n'.join(map(str, df.index.tolist()[slice(row_min,
                                                         row_max+1)]))
     else:  # To copy DataFrame
         if (col_min == 0 or col_min == 1) and (df.shape[1] == col_max):
             header = True
         obj = df.iloc[slice(row_min, row_max+1), slice(col_min-1, col_max)]
         output = io.StringIO()
         obj.to_csv(output, sep='\t', index=index, header=header)
         if not PY2:
             contents = output.getvalue()
         else:
             contents = output.getvalue().decode('utf-8')
         output.close()
     clipboard = QApplication.clipboard()
     clipboard.setText(contents)
开发者ID:rlaverde,项目名称:spyder,代码行数:29,代码来源:dataframeeditor.py

示例13: P

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
 def P(self, repeat):
     """Paste line above current line, paste characters before cursor."""
     editor = self._widget.editor()
     cursor = editor.textCursor()
     text = QApplication.clipboard().text()
     lines = text.splitlines()
     if self._widget.selection_type[1] == 'line':
         text *= repeat
         startBlockPosition = cursor.block().position()
         cursor.movePosition(QTextCursor.StartOfLine)
         cursor.insertText(text)
         cursor.setPosition(startBlockPosition)
         if lines[0].strip():
             cursor.movePosition(QTextCursor.NextWord)
         editor.setTextCursor(cursor)
     elif self._widget.selection_type[1] == 'char':
         startPosition = cursor.position()
         for i in range(repeat):
             editor.paste()
         if len(lines) > 1:
             cursor.setPosition(startPosition)
             editor.setTextCursor(cursor)
     else:
         # TODO: implement pasting block text after implementing visual mode
         pass
     self._widget.update_vim_cursor()
开发者ID:spyder-ide,项目名称:spyder.vim,代码行数:28,代码来源:vim_widget.py

示例14: y

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
 def y(self, repeat):
     """Copy selected line."""
     editor = self._widget.editor()
     selection = editor.get_extra_selections('vim_visual')[0]
     cursor = selection.cursor
     text = cursor.selectedText()
     QApplication.clipboard().setText(text)
     if self.visual_mode == 'char':
         self._update_selection_type('char')
     elif self.visual_mode == 'line':
         self._update_selection_type('line')
     else:
         self._update_selection_type('block')
     editor.setTextCursor(self._prev_cursor)
     self._move_cursor(QTextCursor.StartOfLine)
     self.exit_visual_mode()
开发者ID:spyder-ide,项目名称:spyder.vim,代码行数:18,代码来源:vim_widget.py

示例15: copy_files_clipboard

# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import clipboard [as 别名]
def copy_files_clipboard(create_folders_files):
    """Fixture to copy files/folders into the clipboard"""
    file_paths = create_folders_files[0]
    file_content = QMimeData()
    file_content.setUrls([QUrl.fromLocalFile(fname) for fname in file_paths])
    cb = QApplication.clipboard()
    cb.setMimeData(file_content, mode=cb.Clipboard)
    return file_paths
开发者ID:impact27,项目名称:spyder,代码行数:10,代码来源:test_codeeditor_1.py


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