Last active
March 16, 2022 18:34
-
-
Save oglops/1cb480393039c03cc2bc2b29e7fddf6d to your computer and use it in GitHub Desktop.
drag from script editor to shelf in maya 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PySide2 import QtWidgets, QtGui, QtCore | |
class Window(QtWidgets.QWidget): | |
def __init__(self, *args): | |
QtWidgets.QWidget.__init__(self, *args) | |
layout = QtWidgets.QVBoxLayout(self) | |
label= QtWidgets.QLabel('drop here') | |
label.setAlignment(QtCore.Qt.AlignCenter) | |
layout.addWidget(label) | |
self.setLayout(layout) | |
self.setAcceptDrops(True) | |
def dropEvent(self, event): | |
data = event.mimeData() | |
print('formats:', data.formats()) | |
encoded = data.data('application/x-maya-data') | |
stream = QtCore.QDataStream(encoded, QtCore.QIODevice.ReadOnly) | |
# can not figure out what the structure is in stream though | |
event.acceptProposedAction() | |
def dragEnterEvent(self, e): | |
e.accept() | |
win = Window() | |
win.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment