python类CopyAction()的实例源码

draggabletext.py 文件源码 项目:Mac-Python-3.X 作者: L1nwatch 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event):
        hotSpot = event.pos()

        mimeData = QMimeData()
        mimeData.setText(self.text())
        mimeData.setData('application/x-hotspot',
                '%d %d' % (hotSpot.x(), hotSpot.y()))

        pixmap = QPixmap(self.size())
        self.render(pixmap)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(hotSpot)

        dropAction = drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction)

        if dropAction == Qt.MoveAction:
            self.close()
            self.update()
draggabletext.py 文件源码 项目:examples 作者: pyqt 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event):
        hotSpot = event.pos()

        mimeData = QMimeData()
        mimeData.setText(self.text())
        mimeData.setData('application/x-hotspot',
                '%d %d' % (hotSpot.x(), hotSpot.y()))

        pixmap = QPixmap(self.size())
        self.render(pixmap)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(hotSpot)

        dropAction = drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction)

        if dropAction == Qt.MoveAction:
            self.close()
            self.update()
widgets.py 文件源码 项目:BigBrotherBot-For-UrT43 作者: ptitbigorneau 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def dropEvent(self, event):
        """
        Handle 'Drop' event.
        """
        if event.mimeData().hasUrls():
            B3App.Instance().setOverrideCursor(QCursor(Qt.ArrowCursor))
            event.setDropAction(Qt.CopyAction)
            # multi-drag support
            for url in event.mimeData().urls():
                path = url.path()
                if b3.getPlatform() == 'nt':
                    # on win32 the absolute path returned for each url has a leading slash: this obviously
                    # is not correct on win32 platform when absolute url have the form C:\\Programs\\... (Qt bug?)
                    path = path.lstrip('/').lstrip('\\')
                if os.path.isfile(path):
                    self.parent().parent().make_new_process(path)
            event.accept()
        else:
            event.ignore()

    ############################################ TOOLBAR HANDLERS ######################################################
draggabletext.py 文件源码 项目:pyqt5-example 作者: guinslym 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event):
        hotSpot = event.pos()

        mimeData = QMimeData()
        mimeData.setText(self.text())
        mimeData.setData('application/x-hotspot',
                '%d %d' % (hotSpot.x(), hotSpot.y()))

        pixmap = QPixmap(self.size())
        self.render(pixmap)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(hotSpot)

        dropAction = drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction)

        if dropAction == Qt.MoveAction:
            self.close()
            self.update()
listView.py 文件源码 项目:defconQt 作者: trufont 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def supportedDropActions(self):
        return Qt.CopyAction | Qt.MoveAction
torrent_gui.py 文件源码 项目:bit-torrent 作者: borzunov 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def drag_handler(self, event: QDropEvent, drop: bool=False):
        if event.mimeData().hasUrls():
            event.setDropAction(Qt.CopyAction)
            event.accept()

            if drop:
                self.files_dropped.emit([url.toLocalFile() for url in event.mimeData().urls()])
        else:
            event.ignore()
test_modulator_gui.py 文件源码 项目:urh 作者: jopohl 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_signal_view(self):
        self.add_signal_to_form("esaver.complex")
        signal = self.form.signal_tab_controller.signal_frames[0].signal

        tree_view = self.dialog.ui.treeViewSignals
        tree_model = tree_view.model()
        item = tree_model.rootItem.children[0].children[0]
        index = tree_model.createIndex(0, 0, item)
        rect = tree_view.visualRect(index)
        QTest.mousePress(tree_view.viewport(), Qt.LeftButton, pos=rect.center())
        mime_data = tree_model.mimeData([index])
        drag_drop = QDropEvent(rect.center(), Qt.CopyAction|Qt.MoveAction, mime_data, Qt.LeftButton, Qt.NoModifier)
        drag_drop.acceptProposedAction()
        self.dialog.ui.gVOriginalSignal.dropEvent(drag_drop)
        self.assertEqual(self.dialog.ui.gVOriginalSignal.sceneRect().width(), signal.num_samples)

        self.dialog.ui.cbShowDataBitsOnly.click()
        self.dialog.ui.chkBoxLockSIV.click()

        self.assertEqual(int(self.dialog.ui.gVOriginalSignal.view_rect().width()),
                         int(self.dialog.ui.gVModulated.view_rect().width()))

        freq = self.dialog.ui.doubleSpinBoxCarrierFreq.value()
        self.dialog.ui.btnAutoDetect.click()
        self.assertNotEqual(freq, self.dialog.ui.doubleSpinBoxCarrierFreq.value())

        self.dialog.ui.comboBoxModulationType.setCurrentText("Frequency Shift Keying (FSK)")
        self.dialog.ui.btnAutoDetect.click()

        self.assertEqual(self.dialog.ui.lCurrentSearchResult.text(), "1")
        self.dialog.ui.btnSearchNext.click()
        self.assertEqual(self.dialog.ui.lCurrentSearchResult.text(), "2")
        self.dialog.ui.btnSearchPrev.click()
        self.assertEqual(self.dialog.ui.lCurrentSearchResult.text(), "1")
GeneratorTableModel.py 文件源码 项目:urh 作者: jopohl 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def supportedDropActions(self):
        return Qt.CopyAction | Qt.MoveAction
widgets.py 文件源码 项目:BigBrotherBot-For-UrT43 作者: ptitbigorneau 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def dragEnterEvent(self, event):
        """
        Handle 'Drag Enter' event.
        """
        if event.mimeData().hasUrls():
            B3App.Instance().setOverrideCursor(QCursor(Qt.DragCopyCursor))
            event.setDropAction(Qt.CopyAction)
            event.accept()
        else:
            event.ignore()


问题


面经


文章

微信
公众号

扫码关注公众号