當前位置: 首頁>>代碼示例>>Python>>正文


Python QApplication.clipboard方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QApplication.clipboard方法的典型用法代碼示例。如果您正苦於以下問題:Python QApplication.clipboard方法的具體用法?Python QApplication.clipboard怎麽用?Python QApplication.clipboard使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets.QApplication的用法示例。


在下文中一共展示了QApplication.clipboard方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: saveScreenshot

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def saveScreenshot(self, clipboard=False, fileName='screenshot.png', picType='png'):
        fullWindow = QRect(0, 0, self.width() - 1, self.height() - 1)
        selected = QRect(self.selected_area)
        if selected.left() < 0:
            selected.setLeft(0)
        if selected.right() >= self.width():
            selected.setRight(self.width() - 1)
        if selected.top() < 0:
            selected.setTop(0)
        if selected.bottom() >= self.height():
            selected.setBottom(self.height() - 1)

        source = (fullWindow & selected)
        source.setTopLeft(QPoint(source.topLeft().x() * self.scale, source.topLeft().y() * self.scale))
        source.setBottomRight(QPoint(source.bottomRight().x() * self.scale, source.bottomRight().y() * self.scale))
        image = self.screenPixel.copy(source)

        if clipboard:
            QGuiApplication.clipboard().setImage(QImage(image), QClipboard.Clipboard)
        else:
            image.save(fileName, picType, 10)
        self.target_img = image
        self.screen_shot_grabed.emit(QImage(image)) 
開發者ID:SeptemberHX,項目名稱:screenshot,代碼行數:25,代碼來源:screenshot.py

示例2: changeAction

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def changeAction(self, nextAction):
        QApplication.clipboard().setText('Test in changeAction function')

        if nextAction == ACTION_UNDO:
            self.undoOperation()
        elif nextAction == ACTION_SAVE:
            self.saveOperation()
        elif nextAction == ACTION_CANCEL:
            self.close()
        elif nextAction == ACTION_SURE:
            self.saveToClipboard()

        else:
            self.action = nextAction

        self.setFocus() 
開發者ID:SeptemberHX,項目名稱:screenshot,代碼行數:18,代碼來源:screenshot.py

示例3: ssh_copy_to_clipboard_action

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def ssh_copy_to_clipboard_action(self):
        msg = QMessageBox()
        msg.setStandardButtons(QMessageBox.Ok)
        msg.setParent(self, QtCore.Qt.Sheet)

        index = self.sshComboBox.currentIndex()
        if index > 1:
            ssh_key_filename = self.sshComboBox.itemData(index)
            ssh_key_path = os.path.expanduser(f"~/.ssh/{ssh_key_filename}.pub")
            if os.path.isfile(ssh_key_path):
                pub_key = open(ssh_key_path).read().strip()
                clipboard = QApplication.clipboard()
                clipboard.setText(pub_key)

                msg.setText("Public Key Copied to Clipboard")
                msg.setInformativeText(
                    "The selected public SSH key was copied to the clipboard. "
                    "Use it to set up remote repo permissions."
                )

            else:
                msg.setText("Couldn't find public key.")
        else:
            msg.setText("Select a public key from the dropdown first.")
        msg.exec_() 
開發者ID:Mebus,項目名稱:restatic,代碼行數:27,代碼來源:repo_tab.py

示例4: paste_text

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def paste_text(self):
        sources = QApplication.clipboard().text().splitlines()
        invalidSources = ""
        for source in sources:
            if len(source) > 0:  # Ignore empty newlines
                if not os.path.exists(source):
                    invalidSources = invalidSources + "\n" + source
                else:
                    new_source, created = SourceFileModel.get_or_create(dir=source, profile=self.profile())
                    if created:
                        self.sourceFilesWidget.addItem(source)
                        new_source.save()

        if len(invalidSources) != 0:  # Check if any invalid paths
            msg = QMessageBox()
            msg.setText("Some of your sources are invalid:" + invalidSources)
            msg.exec() 
開發者ID:borgbase,項目名稱:vorta,代碼行數:19,代碼來源:source_tab.py

示例5: ssh_copy_to_clipboard_action

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def ssh_copy_to_clipboard_action(self):
        msg = QMessageBox()
        msg.setStandardButtons(QMessageBox.Ok)
        msg.setParent(self, QtCore.Qt.Sheet)

        index = self.sshComboBox.currentIndex()
        if index > 1:
            ssh_key_filename = self.sshComboBox.itemData(index)
            ssh_key_path = os.path.expanduser(f'~/.ssh/{ssh_key_filename}.pub')
            if os.path.isfile(ssh_key_path):
                pub_key = open(ssh_key_path).read().strip()
                clipboard = QApplication.clipboard()
                clipboard.setText(pub_key)

                msg.setText(self.tr("Public Key Copied to Clipboard"))
                msg.setInformativeText(self.tr(
                    "The selected public SSH key was copied to the clipboard. "
                    "Use it to set up remote repo permissions."))

            else:
                msg.setText(self.tr("Couldn't find public key."))
        else:
            msg.setText(self.tr("Select a public key from the dropdown first."))
        msg.exec_() 
開發者ID:borgbase,項目名稱:vorta,代碼行數:26,代碼來源:repo_tab.py

示例6: onCopyNet

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def onCopyNet(self):
        self.updateLock.acquire()
        
        curRow = self.networkTable.currentRow()
        curCol = self.networkTable.currentColumn()
        
        if curRow == -1 or curCol == -1:
            self.updateLock.release()
            return
        
        if curCol != 11:
            curText = self.networkTable.item(curRow, curCol).text()
        else:
            curNet = self.networkTable.item(curRow, 2).data(Qt.UserRole+1)
            curText = 'Last Recorded GPS Coordinates:\n' + str(curNet.gps)
            curText += 'Strongest Signal Coordinates:\n'
            curText += 'Strongest Signal: ' + str(curNet.strongestsignal) + '\n'
            curText += str(curNet.strongestgps)
            
        clipboard = QApplication.clipboard()
        clipboard.setText(curText)
        
        self.updateLock.release() 
開發者ID:ghostop14,項目名稱:sparrow-wifi,代碼行數:25,代碼來源:sparrow-wifi.py

示例7: createTable

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def createTable(self):
        # Set up location table
        self.locationTable = QTableWidget(self)
        self.locationTable.setColumnCount(8)
        self.locationTable.setGeometry(10, 10, self.geometry().width()/2-20, self.geometry().height()/2)
        self.locationTable.setShowGrid(True)
        self.locationTable.setHorizontalHeaderLabels(['macAddr','SSID', 'Strength', 'Timestamp','GPS', 'Latitude', 'Longitude', 'Altitude'])
        self.locationTable.resizeColumnsToContents()
        self.locationTable.setRowCount(0)
        self.locationTable.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
        
        self.ntRightClickMenu = QMenu(self)
        newAct = QAction('Copy', self)        
        newAct.setStatusTip('Copy data to clipboard')
        newAct.triggered.connect(self.onCopy)
        self.ntRightClickMenu.addAction(newAct)
        
        self.locationTable.setContextMenuPolicy(Qt.CustomContextMenu)
        self.locationTable.customContextMenuRequested.connect(self.showNTContextMenu) 
開發者ID:ghostop14,項目名稱:sparrow-wifi,代碼行數:21,代碼來源:telemetry.py

示例8: onCopy

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def onCopy(self):
        self.updateLock.acquire()
        
        curRow = self.locationTable.currentRow()
        curCol = self.locationTable.currentColumn()
        
        if curRow == -1 or curCol == -1:
            self.updateLock.release()
            return
        
        curText = self.locationTable.item(curRow, curCol).text()
            
        clipboard = QApplication.clipboard()
        clipboard.setText(curText)
        
        self.updateLock.release() 
開發者ID:ghostop14,項目名稱:sparrow-wifi,代碼行數:18,代碼來源:telemetry.py

示例9: send_string_clipboard

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def send_string_clipboard(self, string: str, paste_command: model.SendMode):
        """
        This method is called from the IoMediator for Phrase expansion using one of the clipboard method.
        :param string: The to-be pasted string
        :param paste_command: Optional paste command. If None, the mouse selection is used. Otherwise, it contains a
         keyboard combination string, like '<ctrl>+v', or '<shift>+<insert>' that is sent to the target application,
         causing a paste operation to happen.
        """
        logger.debug("Sending string via clipboard: " + string)
        if common.USING_QT:
            if paste_command is None:
                self.__enqueue(self.app.exec_in_main, self._send_string_selection, string)
            else:
                self.__enqueue(self.app.exec_in_main, self._send_string_clipboard, string, paste_command)
        else:
            if paste_command is None:
                self.__enqueue(self._send_string_selection, string)
            else:
                self.__enqueue(self._send_string_clipboard, string, paste_command)
        logger.debug("Sending via clipboard enqueued.") 
開發者ID:autokey,項目名稱:autokey,代碼行數:22,代碼來源:interface.py

示例10: get_selection

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def get_selection(self):
        """
        Read text from the X selection
        
        Usage: C{clipboard.get_selection()}

        @return: text contents of the mouse selection
        @rtype: C{str}
        @raise Exception: if no text was found in the selection
        """
        Gdk.threads_enter()
        text = self.selection.wait_for_text()
        Gdk.threads_leave()
        if text is not None:
            return text
        else:
            raise Exception("No text found in X selection") 
開發者ID:autokey,項目名稱:autokey,代碼行數:19,代碼來源:scripting.py

示例11: filterKeyPressInHostsTableView

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def filterKeyPressInHostsTableView(self, key, receiver):
        if not receiver.selectionModel().selectedRows():
            return True

        index = receiver.selectionModel().selectedRows()[0].row()

        if key == Qt.Key_Down:
            new_index = index + 1
            receiver.selectRow(new_index)
            receiver.clicked.emit(receiver.selectionModel().selectedRows()[0])
        elif key == Qt.Key_Up:
            new_index = index - 1
            receiver.selectRow(new_index)
            receiver.clicked.emit(receiver.selectionModel().selectedRows()[0])
        elif QApplication.keyboardModifiers() == Qt.ControlModifier and key == Qt.Key_C:
            selected = receiver.selectionModel().currentIndex()
            clipboard = QApplication.clipboard()
            clipboard.setText(selected.data().toString())
        return True 
開發者ID:GoVanguard,項目名稱:legion,代碼行數:21,代碼來源:eventfilter.py

示例12: __init__

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def __init__(self, sender, parent=None):
        super().__init__(parent)
        self.editor = sender
        self.form = parent
        self.timer = QTimer()
        self.timer.setInterval(TRANS_INTERVAL)
        self.timer.start()
        # 信號連接到槽
        self.timer.timeout.connect(self.onTimerOut)
        self.lastTran = ''
        self.lastTranWord = ''
        self.clipboard = QApplication.clipboard()

        self.storeTimer = QTimer()
        self.storeTimer.setInterval(STORE_INTERVAL)
        self.storeTimer.start()
        self.timer.timeout.connect(self.restoreTimeOut)

    # 定義槽 
開發者ID:lkjie,項目名稱:paper-translator,代碼行數:21,代碼來源:paperTran.py

示例13: __init__

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def __init__(self):
        self.app = QApplication(sys.argv)
        self.mainWindow = QMainWindow()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self.mainWindow)

        self.Dialog = QtWidgets.QDialog()
        self.ui2 = Ui_Form()
        self.ui2.setupUi(self.Dialog)

        self.ui.textEdit.setReadOnly(True)
        self.clipboard = QApplication.clipboard()
        self.clipboard.selectionChanged.connect(self.fanyi)
        self.mainWindow.setWindowTitle("劃詞翻譯")
        self.mainWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
        self.ui2.lineEdit.editingFinished.connect(self.callInput)
        self.Dialog.moveEvent = self.mainMove
        self.wordutil = wordutil()
        self.time = time.time()
        self.ui.textEdit.mouseDoubleClickEvent = self.inputText 
開發者ID:copie,項目名稱:dayworkspace,代碼行數:22,代碼來源:fygui.py

示例14: fanyi

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def fanyi(self):
        if time.time() - self.time < 0.1:
            print("停一下")
            return
        self.time = time.time()
        if self.ui.textEdit.hasFocus():
            return
        text = self.clipboard.text(self.clipboard.Selection)
        if len(text) > 20:
            return
        self.mainWindow.move(*self._position())
        texttmp = ""
        for c in text:
            if c.isupper():
                texttmp += " " + c
            else:
                texttmp += c
        text = texttmp
        text = text.strip(' ')
        if text != '':
            text = self.wordutil.execfind(text)
            self.ui.textEdit.clear()
            self.ui.textEdit.insertHtml(text) 
開發者ID:copie,項目名稱:dayworkspace,代碼行數:25,代碼來源:fygui.py

示例15: set_clipboard

# 需要導入模塊: from PyQt5.QtWidgets import QApplication [as 別名]
# 或者: from PyQt5.QtWidgets.QApplication import clipboard [as 別名]
def set_clipboard(data: str, selection: bool = False) -> None:
    """Set the clipboard to some given data."""
    global fake_clipboard
    if selection and not supports_selection():
        raise SelectionUnsupportedError
    if log_clipboard:
        what = 'primary selection' if selection else 'clipboard'
        log.misc.debug("Setting fake {}: {}".format(what, json.dumps(data)))
        fake_clipboard = data
    else:
        mode = QClipboard.Selection if selection else QClipboard.Clipboard
        QApplication.clipboard().setText(data, mode=mode) 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:14,代碼來源:utils.py


注:本文中的PyQt5.QtWidgets.QApplication.clipboard方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。