I'm struggling to get my new UI window parented to the main Maya window. I've been following a few tutorials, but not having much luck combining them.
With the below code (and you can use any UI file you have) I get 2 windows: one that is blank, but parented to the Maya window, and one that is the proper UI file, but is not parented to the Maya window.
I understand that there are 2 times that ui.show is being called, however I don't really understand why the UI's are different.
My end goal is to get the version with the Class & UI file parented to the main Maya window.
import sys
from PySide.QtUiTools import *
from PySide.QtCore import *
from PySide.QtGui import *
def getMayaWindow():
pointer = mui.MQtUtil.mainWindow()
QtGui.QMainWindow.styleSheet(shiboken.wrapInstance(long(pointer), QtGui.QWidget))
return shiboken.wrapInstance(long(pointer), QtGui.QWidget)
class TestApp(QMainWindow):
def __init__(self, parent = getMayaWindow()):
super(TestApp, self).__init__(parent)
loader = QUiLoader()
self.ui = loader.load('c:/pyqt_tutorial.ui')
self.ui.show()
if __name__ == "__main__":
try:
ui.close()
except:
pass
ui = TestApp()
ui.show()