2014-10-28 64 views
0
import maya.OpenMaya as om 
import maya.OpenMayaUI as omUI 

import sip 
from PyQt4 import QtGui, QtCore, uic 

import rpIcons_rc 

import maya.cmds as cmds 
import maya.mel as mel 


def getMayaWindow(): 
# 'Get the maya main window as a QMainWindow instance' 
    ptr = omUI.MQtUtil.mainWindow() 
    return sip.wrapinstance(long(ptr), QtCore.QObject) 

def toQtObject(mayaName): 
    ''' 
    Given the name of a Maya UI element of any type, 
    return the corresponding QWidget or QAction. 
    If the object does not exist, returns None 
    ''' 
    ptr = omUI.MQtUtil.findControl(mayaName) 
    if ptr is None: 
     ptr = omUI.MQtUtil.findLayout(mayaName) 
    if ptr is None: 
     ptr = omUI.MQtUtil.findMenuItem(mayaName) 
    if ptr is not None: 
     return sip.wrapinstance(long(ptr), QtCore.QObject) 

uiFile = ('D:/rpGUI.ui') 
form_class, base_class = uic.loadUiType(uiFile) 

class myUIClass(form_class, base_class): 

    def __init__(self, parent=getMayaWindow()): 
     super(myUIClass, self).__init__(parent) 
     self.setupUi(self) 

     #methods 
     self.connectSignals() 

    def connectSignals(self): 
     """Connect all the UI signals""" 
     print "Connect signals" 


def runUI(): 
    global app 
    global win 
    app=QtGui.qApp 
    win = myUIClass() 
    win.show() 

runUI() 

上面的代码是给错误玛雅2015年的PyQt AttributeError的

错误:AttributeError错误:文件C:\ Program Files文件\欧特克\ Maya2015 \ Python的\ LIB \站点包\ PyQt4的\ uic__init __ PY线215: '模块'对象没有任何属性'QMainWindow'#

所以告诉我这是怎么回事? 谢谢

回答

0

尝试使用Pyside。 Maya 2015与Pyside一起出货。