Skip to content

Instantly share code, notes, and snippets.

@oglops
Last active March 16, 2022 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oglops/1cb480393039c03cc2bc2b29e7fddf6d to your computer and use it in GitHub Desktop.
Save oglops/1cb480393039c03cc2bc2b29e7fddf6d to your computer and use it in GitHub Desktop.
drag from script editor to shelf in maya 2020
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