【发布时间】:2017-10-23 20:06:55
【问题描述】:
如何使用 Python 从主窗口中删除菜单项?我使用 MEL 让它工作,但我在 Python 中也需要它。
不工作的部分是find menu if exists and delete。我似乎在 Python 中找不到等价物。
Python(不工作)
import maya.cmds as cmds
if(???)
{
#cmds.deleteUI('JokerMartini', menu=True )
}
cmds.menu(label='JokerMartini', tearOff=True, p='MayaWindow')
cmds.menuItem(label='Action 1', c= 'something.run()')
cmds.menuItem(divider=True)
cmds.menuItem(label='Action 2', c= 'something.run()')
梅尔(工作中)
if(`menu -exists JokerMartini`)
{
deleteUI JokerMartini;
}
global string $gMainWindow;
setParent $gMainWindow;
menu -label "JokerMartini" -to true -aob true JokerMartini;
menuItem -label "Action 1" -command "something";
menuItem -label "Rename..." -command "something";
【问题讨论】: