Hi All,
Anyone tried to get the selected object name from Maya outliner to a pyqt window ?. I was trying with dropEvent and mimeData. But no clue how to unpack the data. urls never worked. Is there any way to do this ?. Adding on this any one know “application/x-maya-data” what kind of data is this ?
This is the code I am trying.
And the ui file is just a simple dialog with a qlistwidget that's it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os, sip
import maya.cmds as cmds
import maya.OpenMayaUI as mui
from PyQt4 import QtGui, QtCore, uic
def getMayaWindow():
ptr = mui.MQtUtil.mainWindow()
return sip.wrapinstance(long(ptr), QtCore.QObject)
uiFile = "/tmp/drop_test.ui"
form_class, base_class = uic.loadUiType(uiFile)
class loadTestCls(base_class, form_class):
def __init__(self, parent=getMayaWindow()):
super(base_class, self).__init__(parent)
self.setupUi(self)
self.listWidget.setAcceptDrops(True)
self.setWindowTitle("dragNdrop_test")
def dragEnterEvent(self, event):
event.accept()
def dropEvent(self, event):
print event.mimeData().hasFormat("application/x-maya-data")
a = event.mimeData().formats()
print a
def mainLoad():
mlmyWindow = loadTestCls()
mlmyWindow.show()
mainLoad()
Thanks