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'#
所以告訴我這是怎麼回事? 謝謝