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


Python QApplication.clipboard方法代码示例

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


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

示例1: copy_without_prompts

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.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:ImadBouirmane,项目名称:spyder,代码行数:11,代码来源:shell.py

示例2: copy

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.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:gyenney,项目名称:Tools,代码行数:29,代码来源:dataframeeditor.py

示例3: mousePressEvent

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import clipboard [as 别名]
 def mousePressEvent(self, event):
     """Reimplement Qt method"""
     if sys.platform.startswith('linux') and event.button() == Qt.MidButton:
         self.calltip_widget.hide()
         if self.has_selected_text():
             self.remove_selected_text()
         self.setFocus()
         event = QMouseEvent(QEvent.MouseButtonPress, event.pos(),
                             Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
         QPlainTextEdit.mousePressEvent(self, event)
         QPlainTextEdit.mouseReleaseEvent(self, event)
         # Send selection text to clipboard to be able to use
         # the paste method and avoid the strange Issue 1445
         #
         # Note: This issue seems a focusing problem but it
         # seems really hard to track
         mode_clip = QClipboard.Clipboard
         mode_sel = QClipboard.Selection
         text_clip = QApplication.clipboard().text(mode=mode_clip)
         text_sel = QApplication.clipboard().text(mode=mode_sel)
         QApplication.clipboard().setText(text_sel, mode=mode_clip)
         self.paste()
         QApplication.clipboard().setText(text_clip, mode=mode_clip)
     else:
         self.calltip_widget.hide()
         QPlainTextEdit.mousePressEvent(self, event)
开发者ID:dhirschfeld,项目名称:spyderlib,代码行数:28,代码来源:base.py

示例4: paste

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import clipboard [as 别名]
 def paste(self):
     """Reimplemented slot to handle multiline paste action"""
     text = to_text_string(QApplication.clipboard().text())
     if len(text.splitlines()) > 1:
         # Multiline paste
         if self.new_input_line:
             self.on_new_line()
         self.remove_selected_text() # Remove selection, eventually
         end = self.get_current_line_from_cursor()
         lines = self.get_current_line_to_cursor() + text + end
         self.clear_line()
         self.execute_lines(lines)
         self.move_cursor(-len(end))
     else:
         # Standard paste
         ShellBaseWidget.paste(self)
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:18,代码来源:shell.py

示例5: copy

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import clipboard [as 别名]
 def copy(self, index=False, header=False):
     """Copy text to clipboard"""
     (row_min, row_max,
      col_min, col_max) = get_idx_rect(self.selectedIndexes())
     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 df.shape[0] == row_max+1 and row_min == 0:
             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)
         contents = output.getvalue()
         output.close()
     clipboard = QApplication.clipboard()
     clipboard.setText(contents)
开发者ID:jromang,项目名称:spyderlib,代码行数:23,代码来源:dataframeeditor.py

示例6: copy

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import clipboard [as 别名]
 def copy(self):
     """Copy text to clipboard"""
     cliptxt = self._sel_to_text( self.selectedIndexes() )
     clipboard = QApplication.clipboard()
     clipboard.setText(cliptxt)
开发者ID:da-woods,项目名称:spyder,代码行数:7,代码来源:arrayeditor.py

示例7: copy

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

示例8: paste

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import clipboard [as 别名]
 def paste(self):
     """Reimplement Qt method"""
     if self.has_selected_text():
         self.remove_selected_text()
     self.insert_text(QApplication.clipboard().text())
开发者ID:dhirschfeld,项目名称:spyderlib,代码行数:7,代码来源:base.py

示例9: copy_to_clipboard

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import clipboard [as 别名]
 def copy_to_clipboard(self):
     from spyderlib.dependencies import status
     QApplication.clipboard().setText(status())
开发者ID:rthouvenin,项目名称:spyder,代码行数:5,代码来源:dependencies.py


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