import Qt ui to Maya2020

758 views Asked by At

Last week I started learning Python for Maya, following the 'CGCircuit - Learn Python Inside Maya'. Now I'm trying to make a simple UI for Maya2020 using Qt. The tutorial itself is pretty outdated, a lot has changed since Maya2015. I checked a lot of forums and it seems I’m not the only one having problems. This is what I learned so far:

  • Qt designer is not a part of Maya anymore, so I downloaded Qt Creator 4.14.0 (Community)
  • I used pip to install: shiboken2-5.15.2-5.15.2-cp35.cp36.cp37.cp38.cp39-none-win_amd64.whl
  • If I'm correct, Maya2020 has Pyside2 pr-installed, but I also Installed Pyside2 on Windows10
  • QtGui.QDialog is replaced by QWidget Currently I ‘m using Python 2.7.17 on my Windows system, but I also have Python3.8 available in my Environment Variable

When I call the py script inside Maya, like this:

import geomGenerator
reload(geomGenerator)
geomGenerator.getMayaWindow()

geomGenerator.run()

I get this error:

 Error: NameError: file C:/Users/12213119/Documents/maya/2020/scripts\geomGenerator.py line 12: global name 'shiboken2' is not defined #

Not sure what this means or how I can solve it. I looked all over the internet, please let me know what I'm doing wrong. Thx in regard.

from PySide2 import QtGui, QtCore, QtUiTools, QtWidgets
from shiboken2 import wrapInstance

import maya.cmds as mc
import maya.OpenMayaUI as omui

def getMayaWindow():
    """ pointer to the maya main window  
    """
    ptr = omui.MQtUtil.mainWindow()
    if ptr is not None:
        return shiboken2.wrapInstance2(long(ptr), QtWidgets.QWidget)


def run():
    """  builds our UI
    """
    global win
    win = GeometryGenerator(parent=getMayaWindow())
    win.show()

class GeometryGenerator(QtWidgets.QWidget):

    def __init__(self,parent=None):
        super(GeometryGenerator,self).__init__(parent)
1

There are 1 answers

0
mugiseyebrows On

I guess you need to run you script with python that comes with Maya, and use pip that comes with maya to install packages.