Discussion:
[Maya-Python] QT Designer Signal Editor, QUiLoader()
Macbeth R.
2017-03-10 14:21:49 UTC
Permalink
Hi all, I try to migrate some stuff I had been doing from PyQt in Maya2015
to PySide2 in Maya2017.

So first trouble for me is the way the .UI files are being loaded. I saw
an example in devkit folder "devkit\pythonScripts\createNodeUI.py" and it
actually works.

But I am used to create most of my non dynamic signals inside Signal Editor
in QT Designer, and the way the UI is loaded in the example, doesn't allow
the connections to be made from qt designer, I try to load the UI directly
to self, instead of self.ui but it doesn't even gives any error.

Any help is appreciated!! thanks!

This is example I only created a button in Qt designer with a connection to
myFunc()

# Copyright 2015 Autodesk, Inc. All rights reserved.
#
# Use of this software is subject to the terms of the Autodesk
# license agreement provided at the time of installation or download,
# or which otherwise accompanies this software in either electronic
# or hard copy form.

from maya import cmds
from maya import mel
from maya import OpenMayaUI as omui

try:
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2.QtUiTools import *
from shiboken2 import wrapInstance
except ImportError:
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtUiTools import *
from shiboken import wrapInstance


import os.path


mayaMainWindowPtr = omui.MQtUtil.mainWindow()
mayaMainWindow = wrapInstance(long(mayaMainWindowPtr), QWidget)

class CreateNodeUI(QWidget):
def __init__(self, *args, **kwargs):
super(CreateNodeUI,self).__init__(*args, **kwargs)
self.setParent(mayaMainWindow)
self.setWindowFlags( Qt.Window )
self.initUI()

def initUI(self):
loader = QUiLoader()
file = QFile("C:\\test2.ui")
file.open(QFile.ReadOnly)
self.ui = loader.load(file, parentWidget=self)
file.close()


def myFunc(self):
print "Clicked Button"



def main():
ui = CreateNodeUI()
ui.show()
return ui


if __name__ == '__main__':
main()
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7ad88c15-1c4f-4781-97d9-1bb2977bbd09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
2017-03-10 15:18:12 UTC
Permalink
Hi Macbeth,

Have a look here.

- https://github.com/mottosso/Qt.py#load-qt-designer-files
- https://github.com/mottosso/Qt.py/tree/master/examples/load_ui

In short, you can build cross-compatible QtDesigner files if you take
special precautions.

Hope it helps.

Best,
Marcus
​
Post by Macbeth R.
Hi all, I try to migrate some stuff I had been doing from PyQt in Maya2015
to PySide2 in Maya2017.
So first trouble for me is the way the .UI files are being loaded. I saw
an example in devkit folder "devkit\pythonScripts\createNodeUI.py" and it
actually works.
But I am used to create most of my non dynamic signals inside Signal
Editor in QT Designer, and the way the UI is loaded in the example, doesn't
allow the connections to be made from qt designer, I try to load the UI
directly to self, instead of self.ui but it doesn't even gives any error.
Any help is appreciated!! thanks!
This is example I only created a button in Qt designer with a connection
to myFunc()
# Copyright 2015 Autodesk, Inc. All rights reserved.
#
# Use of this software is subject to the terms of the Autodesk
# license agreement provided at the time of installation or download,
# or which otherwise accompanies this software in either electronic
# or hard copy form.
from maya import cmds
from maya import mel
from maya import OpenMayaUI as omui
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2.QtUiTools import *
from shiboken2 import wrapInstance
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtUiTools import *
from shiboken import wrapInstance
import os.path
mayaMainWindowPtr = omui.MQtUtil.mainWindow()
mayaMainWindow = wrapInstance(long(mayaMainWindowPtr), QWidget)
super(CreateNodeUI,self).__init__(*args, **kwargs)
self.setParent(mayaMainWindow)
self.setWindowFlags( Qt.Window )
self.initUI()
loader = QUiLoader()
file = QFile("C:\\test2.ui")
file.open(QFile.ReadOnly)
self.ui = loader.load(file, parentWidget=self)
file.close()
print "Clicked Button"
ui = CreateNodeUI()
ui.show()
return ui
main()
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit https://groups.google.com/d/
msgid/python_inside_maya/7ad88c15-1c4f-4781-97d9-
1bb2977bbd09%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/7ad88c15-1c4f-4781-97d9-1bb2977bbd09%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
*Marcus Ottosson*
***@gmail.com
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBj05iyEzVnb2_112StbGxQ3ZChbOtC23%3DhodiifX%3DLBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...