Ruchit
Ruchit

Reputation: 681

Maya 2015 PyQt AttributeError

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()

Above code is giving Error

Error: AttributeError: file C:\Program Files\Autodesk\Maya2015\Python\lib\site-packages\PyQt4\uic__init__.py line 215: 'module' object has no attribute 'QMainWindow' #

So tell me wht's wrong going on ?? Thank you

Upvotes: 0

Views: 640

Answers (1)

kartikg3
kartikg3

Reputation: 2620

Try using Pyside. Maya 2015 ships with Pyside.

Upvotes: 0

Related Questions