Delete all menuItems in a menu, without deleting the menu itself?

23 views
Skip to first unread message

Tim Crowson

unread,
Apr 23, 2014, 11:44:24 AM4/23/14
to python_in...@googlegroups.com
I have a submenu whose contents I want to update, but I don't want to change the position of the submenu in its parent menu. I'm assuming that deleting the submenu and recreating it would recreate it at the end of the parent menu (?)....

But I'm curious if I can use cmds.deleteUI() with the menuItems flag, but instead of specificying which menuitems I want to delete... just delete all the menuitems instead. The only flags I see for that method are object-specific. Is there a way to loop over menuItems and delete each one perhaps?

-Tim

Tim Crowson

unread,
Apr 23, 2014, 11:53:55 AM4/23/14
to python_in...@googlegroups.com
Ah I found this snippet that seems like what I need...

def clearList(self, *args):
    menuItems = cmds.optionMenu('optionMenu', q=True, itemListLong=True) # itemListLong returns the children
    if menuItems:
        cmds.deleteUI(menuItems)
Reply all
Reply to author
Forward
0 new messages