答案 0 :(得分:2)
从上面的文档中,我认为您可以使用以下命令:
cmds.window()
cmds.columnLayout('r')
myShader = 'ramp2'
cmds.swatchDisplayPort('slPP', wh=(256, 256), sn=myShader)
cmds.showWindow()
如果您使用的是PySide或PyQt,则有些棘手,您可能必须使用mayaAPI来找到此命令的指针。
from PyQt5 import QtWidgets, QtGui, QtCore
from sip import wrapinstance
import maya.cmds as cmds
import maya.OpenMayaUI as omui
def mayaToQT( name ):
# Maya -> QWidget
ptr = omui.MQtUtil.findControl( name )
if ptr is None: ptr = omui.MQtUtil.findLayout( name )
if ptr is None: ptr = omui.MQtUtil.findMenuItem( name )
if ptr is not None: return wrapinstance( long( ptr ), QtWidgets.QWidget )
myShader = 'ramp2'
control = cmds.swatchDisplayPort('slPP', wh=(256, 256), sn=myShader)
swatchQT_ramp2 = mayaToQT(control)
,然后将该对象转换回您的ui并添加到pyside / pyqt中!