class faceInterface(base_class, form_class):
def init(self):
super(base_class, self).init()
self.setupUi(self)
self.setobjectName(‘faceInterface’)
self.setDockNestingEnabled(True)
Main
def main():
global ui
ui = faceInterface()
ui.show()
if name == “main”:
main()
i use maya 2012 x64
and i use this code to get the ui in to maya
import sys
Dir = ‘E:\faceui’
if Dir not in sys.path:
sys.path.append(Dir)
try: reload(faceInterface.ui)
except: import faceInterface.ui
faceInterface.ui.main()
…
it’s my first time using qt into maya so please help becouse i have this problem
when i run the code :
import sys
Dir = ‘E:\faceui’
if Dir not in sys.path:
sys.path.append(Dir)
try: reload(faceInterface.ui)
except: import faceInterface.ui
faceInterface.ui.main()
Error: ImportError: No module named faceInterface.ui
You’re trying to load/reload faceInterface.ui as if it were a python module. The ui file is QT forms designer xml, and can’t be loaded this way. Since you can’t load a .ui file directly, you would have to “compile” the UI as a python file. Normally, this file would be called faceInterface.py, but you already have created a file that uses this name. If you want to pursue this approach, rename your current python file to something else and look at the PyQT docs on how to compile interfaces to python code.
However, instead of jumping through all these hoops, take a look at the new loadUI command that has been added to Maya:
He doesn’t need to compile to python code if he’s using uic to convert it on the fly like that with loadUiType.
if you python script is called faceInterface.py and is in the system path:
import faceInterface
faceInterface.main()
Also, the new loadUI command is garbage, don’t use it. You can’t use signals/slots, you can’t overload widget methods or subclass and promote widgets. basically just takes the form for a qt ui and converts it to Maya’s old ELF style of handling ui’s. What he is doing with loadUiType is the proper way to load in a qt form and subclass it.
I second the motion that the loadUI command is garbage.
Related question, if you’re writing an internal tool for a commercial project, do you need to buy the commercial license for Qt, even though you’re not selling the tool itself?
[QUOTE=lkruel;10796]I second the motion that the loadUI command is garbage.
Related question, if you’re writing an internal tool for a commercial project, do you need to buy the commercial license for Qt, even though you’re not selling the tool itself?[/QUOTE]
Internal tools that don’t get released can usually use an open source license. But I’m no lawyer, and some companies will have internal policies against open source code as well.
I think pyside is licensed under the LGPL rather than the GPL like PyQt, so once that works correctly under Windows x64 that’s probably a much safer bet licensing wise. Qt itself is already available as LGPL, which is much less restrictive. Building internal tools with that should have no issues.
If you sell your tools then it’s a whole different story of course.
Interesting. We’re moving from 2009 to 2012, so we’re still using QT “bolted on the side”. I’ll have to play with uic. I notice that he’s using 4.7.3. Has anyone seen incompatible .ui code coming out of later designers? Also, if you use uic to load the ui, is it a child window of Maya?
[QUOTE=Temujin;10791]He doesn’t need to compile to python code if he’s using uic to convert it on the fly like that with loadUiType.
if you python script is called faceInterface.py and is in the system path:
import faceInterface
faceInterface.main()
Also, the new loadUI command is garbage, don’t use it. You can’t use signals/slots, you can’t overload widget methods or subclass and promote widgets. basically just takes the form for a qt ui and converts it to Maya’s old ELF style of handling ui’s. What he is doing with loadUiType is the proper way to load in a qt form and subclass it.[/QUOTE]
the .ui code is pretty generic xml, so there shouldn’t be many if any compatibility issues. I’ve used the same designer files from 4.5 in 4.7 and they worked fine.
Your widget will be a top level window if you use uic, but you can cast the Maya main window to a QWidget and use that in your constructor to parent below it.
I have an example of fetching the Maya main window widget here: http://nathanhorne.com/?p=298