Blog Content

Home – Blog Content

How I Work: Maya, Qt & PySide

[I’m improving this page, WIP]

There are plenty of ways to get up to speed with an IDE for developing Maya tools & plugins. Anecdotally, I’ve found not many studios enforce a particular IDE for Maya development, so this is how I’ve usually got mine configured.


  1. Python 2.7.11 – this is the version Maya uses [2019, anyway].
  2. Qt Opensource Windows 5.6.1 (mingw) We’re not modifying code here, we’re simply using an included tool for building Qt interfaces for Maya
  3. I also like to install the developer API, so we have access to the Maya API. You can download this from this page (its a bit far down, you need to look for it properly): https://www.autodesk.com/developer-network/platform-technologies/maya
  4. An IDE – I use Visual Studio, but VS Code & Eclipse work fine.

Getting Started

Once you’ve installed those tools, locate where you installed Qt to, and find this application:


Put a shortcut to this on your Desktop (or wherever). You can run this to build Maya-compatible .UI files

Next, run Maya and run this command in Python:

import maya.cmds as cmds
cmds.commandPort(name=":7001", sourceType="mel")
cmds.commandPort(name=":7002", sourceType="python")

You can, if you wish, add this to you userSetup.py/userSetup.mel file in your Maya scripts path.

This opens Maya listening ports, so you can use your IDE to send Python text to Maya. If you use Visual Studio you can look at MayaPort to get you connected up in there (I have my own custom VS Extension for VS2019, but its not ready for a public release).

I also head into VS and add in the Maya Python paths, so you get all the Maya-specific PyMEL commands. You can do this by adding Maya’s python interpreters to a new environment:

Open up Designer and make yourself a basic UI, like so:

Save this as “MyCustomUiFile.ui” in:
C:\Users\<username>\Documents\Maya\<maya version, i,e, ‘2019’>\scripts\

Now, you can use the following termplate to open the UI and hook up events:

import os
import sys
import site
from PySide2.QtCore import SIGNAL
  from PySide2.QtCore import *
  from PySide2.QtGui import *
  from PySide2.QtWidgets import *
  from PySide2 import __version__
  from shiboken2 import wrapInstance
except ImportError:
  from PySide.QtCore import *
  from PySide.QtGui import *
  from PySide import __version__
  from shiboken import wrapInstance
from maya import OpenMayaUI as omui
from PySide2.QtUiTools import  *
from pymel.all import *
import maya
import maya.cmds as cmds
import pymel.core as pm
import pymel.mayautils as mutil
mayaMainWindowPtr = omui.MQtUtil.mainWindow()
mayaMainWindow = wrapInstance(long(mayaMainWindowPtr), QWidget)
windowId = "MyCustomUI"
USERNAME = os.getenv('USERNAME')
def loadUiWidget(uifilename, parent=None):
    """Properly Loads and returns UI files - by BarryPye on stackOverflow"""
    loader = QUiLoader()
    uifile = QFile(uifilename)
    ui = loader.load(uifile, parent)
    return ui
class createMyCustomUI(QMainWindow):
    uiPath = "C:\\Users\\" + USERNAME + "\\Documents\\maya\\2019\\scripts\\MyCustomScript\\UI\\MyCustomUiFile.ui"
    def onExitCode(self):
        print("DEBUG: UI Closed!\n")
    def __init__(self):
        print("Opening UI at " + self.uiPath)
        mainUI = self.uiPath
        MayaMain = wrapInstance(long(omui.MQtUtil.mainWindow()), QWidget)
        super(createMyCustomUI, self).__init__(MayaMain)
        # main window load / settings
        self.MainWindowUI = loadUiWidget(mainUI, MayaMain)
        self.MainWindowUI.setAttribute(Qt.WA_DeleteOnClose, True) 
        # You can use code like below to implement functions on the UI itself:
    #def doOk(self):
        #print("Ok Button Pressed")
if not (cmds.window(windowId, exists=True)):
    sys.stdout.write("tool is already open!\n")

That should at least get you going with a basic interface to work from.

Leave a Reply



Privacy Policy

Terms & Condition


Contact Us


About Us


Latest News

© 2023 half4.xyz ltd. Created with Royal Elementor Addons