玛雅独立与pyside2
maya standalone with pyside2
当我想在 Maya 中独立添加 QtWidget 时,出现错误提示“QWidget:无法在没有 QApplication 的情况下创建 QWidget”。
from PySide2 import QtWidgets
import maya.standalone
maya.standalone.initialize()
QtWidgets.QPushButton()
maya.standalone.uninitialize()
然后我添加了一个 QApplication,错误提示:“一个 QApplication 实例已经存在。”
from PySide2 import QtWidgets
import maya.standalone
import sys
maya.standalone.initialize()
QtWidgets.QApplication(sys.argv)
QtWidgets.QPushButton()
maya.standalone.uninitialize()
我用QApplication.instance()
我可以得到一个'QGuiApplication'参考,所以
我知道 maya.standalone() 将创建 qApp,但是如何创建 QWidget(例如对话框...)
============================================= ===================
from PySide2 import QtWidgets
import maya.standalone
maya.standalone.initialize()
print(QtWidgets.QApplication.instance())
maya.standalone.uninitialize()
这是完整的日志:
pymel.core : INFO : Updating pymel with pre-loaded plugins: renderSetup
Warning: file: C:/Program Files/Autodesk/Maya2018/scripts/startup/initialStartup.mel line 179: Y-axis is already the Up-axis
Warning: file: C:\Users\a\Documents\maya18\prefs\filePathEditorRegistryPrefs.mel line 4: filePathEditor: Attribute 'aiImage.filename' is invalid or is not designated 'usedAsFilename'.
Warning: file: C:\Users\a\Documents\maya18\prefs\filePathEditorRegistryPrefs.mel line 5: filePathEditor: Attribute 'aiPhotometricLight.aiFilename' is invalid or is not designated
'usedAsFilename'.
Warning: file: C:\Users\a\Documents\maya18\prefs\filePathEditorRegistryPrefs.mel line 6: filePathEditor: Attribute 'aiStandIn.dso' is invalid or is not designated 'usedAsFilename'.
Warning: file: C:\Users\a\Documents\maya18\prefs\filePathEditorRegistryPrefs.mel line 7: filePathEditor: Attribute 'aiVolume.filename' is invalid or is not designated 'usedAsFilename'.
AbcExport v1.0 using Alembic 1.7.5 (built Feb 6 2018 18:28:08)
Initialized VP2.0 renderer {
Version : 2016.11.40.12. Feature Level 5.
Adapter : GeForce RTX 3090/PCIe/SSE2
Vendor ID: 4318. Device ID : 8708
Driver : .
API : OpenGL V.4.6.
Max texture size : 16384 * 16384.
Max tex coords : 32
Shader versions supported (Vertex: 5, Geometry: 5, Pixel 5).
Shader compiler profile : (Best card profile)
Active stereo support available : 0
GPU Memory Limit : 24576 MB.
CPU Memory Limit: 62178.5 MB.
MultiDraw consolidation: enabled
}
OpenCL evaluator is attempting to initialize OpenCL.
Detected 1 OpenCL Platforms:
0: NVIDIA Corporation. NVIDIA CUDA. OpenCL 1.2 CUDA 11.2.162.
Supported extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_d3d10_sharing cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts cl_nv_create_buffer cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_device_uuid
OpenCL evaluator choosing OpenCL platform NVIDIA Corporation.
OpenCL evaluator is unable to find a GPU device that can share VBOs with OpenGL.
Warning: file: C:/Program Files/Autodesk/Maya2018/scripts/startup/autoLoadPlugin.mel line 35: Loading plug-in "lookdevKit" has resulted in changes to the scene that may need to be saved.
AbcImport v1.0 using Alembic 1.7.5 (built Feb 6 2018 18:28:08)
<PySide2.QtGui.QGuiApplication object at 0x000001828E9D9108>
如果没有先前的 QXApplication,initialize()
函数会创建一个 QGuiApplication,因此一种可能是在调用该函数之前创建一个 QApplication:
app = QtWidgets.QApplication(sys.argv)
maya.standalone.initialize()
当我想在 Maya 中独立添加 QtWidget 时,出现错误提示“QWidget:无法在没有 QApplication 的情况下创建 QWidget”。
from PySide2 import QtWidgets
import maya.standalone
maya.standalone.initialize()
QtWidgets.QPushButton()
maya.standalone.uninitialize()
然后我添加了一个 QApplication,错误提示:“一个 QApplication 实例已经存在。”
from PySide2 import QtWidgets
import maya.standalone
import sys
maya.standalone.initialize()
QtWidgets.QApplication(sys.argv)
QtWidgets.QPushButton()
maya.standalone.uninitialize()
我用QApplication.instance()
我可以得到一个'QGuiApplication'参考,所以
我知道 maya.standalone() 将创建 qApp,但是如何创建 QWidget(例如对话框...)
============================================= ===================
from PySide2 import QtWidgets
import maya.standalone
maya.standalone.initialize()
print(QtWidgets.QApplication.instance())
maya.standalone.uninitialize()
这是完整的日志:
pymel.core : INFO : Updating pymel with pre-loaded plugins: renderSetup
Warning: file: C:/Program Files/Autodesk/Maya2018/scripts/startup/initialStartup.mel line 179: Y-axis is already the Up-axis
Warning: file: C:\Users\a\Documents\maya18\prefs\filePathEditorRegistryPrefs.mel line 4: filePathEditor: Attribute 'aiImage.filename' is invalid or is not designated 'usedAsFilename'.
Warning: file: C:\Users\a\Documents\maya18\prefs\filePathEditorRegistryPrefs.mel line 5: filePathEditor: Attribute 'aiPhotometricLight.aiFilename' is invalid or is not designated
'usedAsFilename'.
Warning: file: C:\Users\a\Documents\maya18\prefs\filePathEditorRegistryPrefs.mel line 6: filePathEditor: Attribute 'aiStandIn.dso' is invalid or is not designated 'usedAsFilename'.
Warning: file: C:\Users\a\Documents\maya18\prefs\filePathEditorRegistryPrefs.mel line 7: filePathEditor: Attribute 'aiVolume.filename' is invalid or is not designated 'usedAsFilename'.
AbcExport v1.0 using Alembic 1.7.5 (built Feb 6 2018 18:28:08)
Initialized VP2.0 renderer {
Version : 2016.11.40.12. Feature Level 5.
Adapter : GeForce RTX 3090/PCIe/SSE2
Vendor ID: 4318. Device ID : 8708
Driver : .
API : OpenGL V.4.6.
Max texture size : 16384 * 16384.
Max tex coords : 32
Shader versions supported (Vertex: 5, Geometry: 5, Pixel 5).
Shader compiler profile : (Best card profile)
Active stereo support available : 0
GPU Memory Limit : 24576 MB.
CPU Memory Limit: 62178.5 MB.
MultiDraw consolidation: enabled
}
OpenCL evaluator is attempting to initialize OpenCL.
Detected 1 OpenCL Platforms:
0: NVIDIA Corporation. NVIDIA CUDA. OpenCL 1.2 CUDA 11.2.162.
Supported extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_d3d10_sharing cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts cl_nv_create_buffer cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_device_uuid
OpenCL evaluator choosing OpenCL platform NVIDIA Corporation.
OpenCL evaluator is unable to find a GPU device that can share VBOs with OpenGL.
Warning: file: C:/Program Files/Autodesk/Maya2018/scripts/startup/autoLoadPlugin.mel line 35: Loading plug-in "lookdevKit" has resulted in changes to the scene that may need to be saved.
AbcImport v1.0 using Alembic 1.7.5 (built Feb 6 2018 18:28:08)
<PySide2.QtGui.QGuiApplication object at 0x000001828E9D9108>
如果没有先前的 QXApplication,initialize()
函数会创建一个 QGuiApplication,因此一种可能是在调用该函数之前创建一个 QApplication:
app = QtWidgets.QApplication(sys.argv)
maya.standalone.initialize()