PyQt :
Developing PyQt applications for Maya is basically divided into three parts :
1. Interface - developed in QT Designer.
2. Framework /
Application code - written in Python editor.
3. Maya Code - written in Maya to call framework/application.
1. Interface - create desired interface in QT Designer and save it as "interfaceUI.ui"
2. Framework: save following code as - "filename.py"
from PyQt4 import QtGui, QtCore, uic
from pymel.core import *
import pymel.core as pm
# Path to the Qt Designer UI file
ui_filename = 'C:/QtSDK/interfaceFile.ui'
form_class, base_class = uic.loadUiType(ui_filename)
# Interface Class
class Exporter(base_class, form_class):
# Main
def main ():
global ui
ui = Exporter()
ui.show()
if __name__ == "__main__":
main()
3. Maya Calling Code :
import sys
Dir = 'c:/QtSDK/test'
if Dir not in sys.path:
sys.path.append(Dir)
try:
reload(filename)
except:
import filename
filename.main()
Developing PyQt applications for Maya is basically divided into three parts :
1. Interface - developed in QT Designer.
2. Framework /
Application code - written in Python editor.
3. Maya Code - written in Maya to call framework/application.
1. Interface - create desired interface in QT Designer and save it as "interfaceUI.ui"
2. Framework: save following code as - "filename.py"
from PyQt4 import QtGui, QtCore, uic
from pymel.core import *
import pymel.core as pm
# Path to the Qt Designer UI file
ui_filename = 'C:/QtSDK/interfaceFile.ui'
form_class, base_class = uic.loadUiType(ui_filename)
# Interface Class
class Exporter(base_class, form_class):
def __init__(self):
super(base_class,self).__init__()
self.setupUi(self)
self.setObjectName('WindowName')
self.setDockNestingEnabled(True)
# Main
def main ():
global ui
ui = Exporter()
ui.show()
if __name__ == "__main__":
main()
3. Maya Calling Code :
import sys
Dir = 'c:/QtSDK/test'
if Dir not in sys.path:
sys.path.append(Dir)
try:
reload(filename)
except:
import filename
filename.main()
Comments