Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

PySide: maya.OpenMayaUI.MQtUtil.mainWindow() returning SwigPyObject

PySide: maya.OpenMayaUI.MQtUtil.mainWindow() returning SwigPyObject

Anonymous
Not applicable
2,835 Views
1 Reply
Message 1 of 2

PySide: maya.OpenMayaUI.MQtUtil.mainWindow() returning SwigPyObject

Anonymous
Not applicable

Hi, I'm using Maya 2014. Apparently you don't have to build anything to use PySide.

According to this:

http://docs.autodesk.com/MAYAUL/2014/ENU/Maya-API-Documentation/index.html?url=files/GUID-66ADA1FF-3...

 

You get the main window by using maya.OpenMayaUI.MQtUtil.mainWindow() then pass that result to shiboken.wrapInstance. mainWindow() returns a SwigPyObject that always causes an error when using shiboken.wrapInstance that says: Error: TypeError: You need a shiboken-based type.

0 Likes
2,836 Views
1 Reply
Reply (1)
Message 2 of 2

cyrille
Alumni
Alumni

Hi

 

I just run the following script with no issue

 

import sys
import maya.OpenMayaUI as mui
from PySide import QtCore, QtGui
import shiboken

def getMayaWindow():
  # Get the maya main window as a QMainWindow instance
  ptr = mui.MQtUtil.mainWindow()
  return shiboken.wrapInstance(long(ptr), QtGui.QMainWindow)

 

print getMayaWindow()


Remember that PySide unlike PyQT returns the exact object, whereas PyQT returns the best match. That means the 2nd parameter has a strong importance.
 
Hope that helps,
0 Likes