上周,我开始为玛雅学习Python,遵循“CGCircuit-学习玛雅里面的Python”。现在,我正在尝试使用Qt为Maya2020创建一个简单的UI。本教程本身已经非常过时,自Maya2015以来已经发生了很大变化。我查看了很多论坛,似乎我不是唯一一个有问题的人。这就是我到目前为止学到的:
shiboken2-5.15.2-5.15.2-cp35.cp36.cp37.cp38.cp39-none-win_amd64.whl
中也有Python3.8可用
当我调用Maya内部的py脚本时,如下所示:
import geomGenerator
reload(geomGenerator)
geomGenerator.getMayaWindow()
geomGenerator.run()我知道这个错误:
Error: NameError: file C:/Users/12213119/Documents/maya/2020/scripts\geomGenerator.py line 12: global name 'shiboken2' is not defined #不知道这意味着什么或者我怎么能解决它。我在网上到处找,请让我知道我做错了什么。在这方面。
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)发布于 2021-01-23 12:52:36
我想您需要使用Maya附带的python运行脚本,并使用maya附带的pip来安装软件包。
https://stackoverflow.com/questions/65858944
复制相似问题