I’m taking a simple PyQt UI from Maya 2013 and converting to Pyside for maya 2014 and I’ve hit a snag. My UI does not use a .ui file, it is a very simple tool.
I’ve followed along with some of the findings by Nathan Horne and Jason Parks, but I am hitting snag I haven’t seen covered since most of their examples assume you have a .ui file to load.
Here is the error I get:
# Error: TypeError: file ********.py line 40: 'PySide.QtGui.QWidget' called with wrong argument types:
PySide.QtGui.QWidget(PySide.QtCore.QObject)
Supported signatures:
PySide.QtGui.QWidget(PySide.QtGui.QWidget = None, PySide.QtCore.Qt.WindowFlags = 0) #
Here is what my class looks like:
class MyUIClass(QtGui.QWidget):
def __init__(self, parent=getMayaMainWindow()):
super(MyUIClass, self).__init__(parent) # <--- This is where the error is occuring.
Not sure what Pyside is expecting… thanks!
I found the source of the problem. The problem arose from using code snippets from two sources that weren’t compatible with each other.
I needed to modify Nathan’s getMayaMainWindow to use the Pyside wrapinstance function
Original:
def getMayaWindow():
"""
Get the main Maya window as a QtGui.QMainWindow instance
@return: QtGui.QMainWindow instance of the top level Maya windows
"""
ptr = apiUI.MQtUtil.mainWindow()
if ptr is not None:
return sip.wrapinstance(long(ptr), QtCore.QObject)
Modified in bold:
def getMayaWindow():
"""
Get the main Maya window as a QtGui.QMainWindow instance
@return: QtGui.QMainWindow instance of the top level Maya windows
"""
ptr = apiUI.MQtUtil.mainWindow()
if ptr is not None:
[B]return wrapinstance(long(ptr))[/B]
Was having the exact same issue today, but I get a typeError when I try this:
# TypeError: wrapInstance expected 2 arguments, got 1 #
What worked for me is this:
return wrapInstance(long(accessMainWindow), QtGui.QWidget)