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


Python QApplication.clipboard方法代码示例

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


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

示例1: copy_to_clipboard

# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import clipboard [as 别名]
 def copy_to_clipboard(self, indexes):
     '''
     Copy the selected path to the clipboard
     '''
     mimeData = QMimeData()
     text = ''
     for index in indexes:
         if index.isValid():
             item = self.itemFromIndex(index)
             prev = '%s\n' % text if text else ''
             text = '%sfile://%s' % (prev, item.path)
     mimeData.setData('text/plain', text.encode('utf-8'))
     QApplication.clipboard().setMimeData(mimeData)
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:15,代码来源:launch_list_model.py

示例2: paste_from_clipboard

# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import clipboard [as 别名]
 def paste_from_clipboard(self):
     '''
     Copy the file or folder to new position...
     '''
     if QApplication.clipboard().mimeData().hasText() and self.currentPath:
         text = QApplication.clipboard().mimeData().text()
         if text.startswith('file://'):
             path = text.replace('file://', '')
             basename = os.path.basename(text)
             ok = True
             if os.path.exists(os.path.join(self.currentPath, basename)):
                 basename, ok = QInputDialog.getText(None, 'File exists', 'New name (or override):', QLineEdit.Normal, basename)
             if ok and basename:
                 if os.path.isdir(path):
                     shutil.copytree(path, os.path.join(self.currentPath, basename))
                 elif os.path.isfile(path):
                     shutil.copy2(path, os.path.join(self.currentPath, basename))
                 self.reloadCurrentPath()
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:20,代码来源:launch_list_model.py

示例3: _copy_text_to_clipboard

# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import clipboard [as 别名]
 def _copy_text_to_clipboard(self):
     # Get tab indented text for all selected items
     def get_distance(item, ancestor, distance=0):
         parent = item.parent()
         if parent == None:
             return distance
         else:
             return get_distance(parent, ancestor, distance + 1)
     text = ''
     for i in self.get_all_items():
         if i in self.selectedItems():
             text += ('\t' * (get_distance(i, None))) + i.text(0) + '\n'
     # Copy the text to the clipboard
     clipboard = QApplication.clipboard()
     clipboard.setText(text)
开发者ID:OSUrobotics,项目名称:rqt_common_plugins,代码行数:17,代码来源:raw_view.py

示例4: actionPaste

# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import clipboard [as 别名]
 def actionPaste(self):
     # Also called by handleOS_SIGUSR1_2
     textArea = self.gui.speechInputFld
     currCursor = textArea.textCursor()
     currCursor.insertText(QApplication.clipboard().text())
开发者ID:ros-visualization,项目名称:speakeasy,代码行数:7,代码来源:speakeasy_controller.py

示例5: _rightclick_menu

# 需要导入模块: from python_qt_binding.QtGui import QApplication [as 别名]
# 或者: from python_qt_binding.QtGui.QApplication import clipboard [as 别名]
    def _rightclick_menu(self, event):
        """
        Dynamically builds the rightclick menu based on the unique column data
        from the passed in datamodel and then launches it modally
        :param event: the mouse event object, ''QMouseEvent''
        """
        severities = {}
        for severity, label in Message.SEVERITY_LABELS.items():
            if severity in self._model.get_unique_severities():
                severities[severity] = label
        nodes = sorted(self._model.get_unique_nodes())
        topics = sorted(self._model.get_unique_topics())

        # menutext entries turned into
        menutext = []
        menutext.append([self.tr('Exclude'), [[self.tr('Severity'), severities], [self.tr('Node'), nodes], [self.tr('Topic'), topics], [self.tr('Selected Message(s)')]]])
        menutext.append([self.tr('Highlight'), [[self.tr('Severity'), severities], [self.tr('Node'), nodes], [self.tr('Topic'), topics], [self.tr('Selected Message(s)')]]])
        menutext.append([self.tr('Copy Selected')])
        menutext.append([self.tr('Browse Selected')])

        menu = QMenu()
        submenus = []
        subsubmenus = []
        for item in menutext:
            if len(item) > 1:
                submenus.append(QMenu(item[0], menu))
                for subitem in item[1]:
                    if len(subitem) > 1:
                        subsubmenus.append(QMenu(subitem[0], submenus[-1]))
                        if isinstance(subitem[1], dict):
                            for key in sorted(subitem[1].keys()):
                                action = subsubmenus[-1].addAction(subitem[1][key])
                                action.setData(key)
                        else:
                            for subsubitem in subitem[1]:
                                subsubmenus[-1].addAction(subsubitem)
                        submenus[-1].addMenu(subsubmenus[-1])
                    else:
                        submenus[-1].addAction(subitem[0])
                menu.addMenu(submenus[-1])
            else:
                menu.addAction(item[0])
        action = menu.exec_(event.globalPos())

        if action is None or action == 0:
            return
        elif action.text() == self.tr('Browse Selected'):
            self._show_browsers()
        elif action.text() == self.tr('Copy Selected'):
            rowlist = []
            for current in self.table_view.selectionModel().selectedIndexes():
                rowlist.append(self._proxy_model.mapToSource(current).row())
            copytext = self._model.get_selected_text(rowlist)
            if copytext is not None:
                clipboard = QApplication.clipboard()
                clipboard.setText(copytext)
        elif action.text() == self.tr('Selected Message(s)'):
            if action.parentWidget().title() == self.tr('Highlight'):
                self._process_highlight_exclude_filter(action.text(), 'Message', False)
            elif action.parentWidget().title() == self.tr('Exclude'):
                self._process_highlight_exclude_filter(action.text(), 'Message', True)
            else:
                raise RuntimeError("Menu format corruption in ConsoleWidget._rightclick_menu()")
        else:
            # This processes the dynamic list entries (severity, node and topic)
            try:
                roottitle = action.parentWidget().parentWidget().title()
            except:
                raise RuntimeError("Menu format corruption in ConsoleWidget._rightclick_menu()")

            if roottitle == self.tr('Highlight'):
                self._process_highlight_exclude_filter(action.text(), action.parentWidget().title(), False)
            elif roottitle == self.tr('Exclude'):
                self._process_highlight_exclude_filter(action.text(), action.parentWidget().title(), True)
            else:
                raise RuntimeError("Unknown Root Action %s selected in ConsoleWidget._rightclick_menu()" % roottitle)
开发者ID:OSUrobotics,项目名称:rqt_common_plugins,代码行数:78,代码来源:console_widget.py


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