I've been playing around with adding menus to the UI and I've looked into 
doing it with maya.cmds, pymel and the Qt module itself.
This is not really a major issue, but I'd still like to understand how i 
could delete a menu from Maya's main window bar(File, Edit, Select, Create, 
etc.) by using the label name.
I created a menu item of my own and accidentally forgot to give it a name 
and to store the return in a variable. All it has is a label.
Besides using the Qt module I'm not sure how to get the menuitems from 
either PyMEL or maya.cmds.

For instance:
from PySide2 import QtWidgets, QtCore
import shiboken2
import maya.OpenMayaUI as omui

winPtr = omui.MQtUtil.mainWindow()
mayaWindow = shiboken2.wrapInstance(int(winPtr), QtWidgets.QWidget)

#we got the MayaWindow pointer, now let's grab the QMenubar
menubar = ""
for child in mayaWindow.children():
    if isinstance(child, PySide2.QtWidgets.QMenuBar):
        menubar = child

itemToDel = ''
#then from this main menu bar, get the TopMenu Titles
for topmenu in menubar.actions():
    if topmenu.isVisible():
        if topmenu.text()=='My Menu':
            itemToDel = topmenu
            break

So now I have the menu item in a QAction object. But unsure how I can use 
that to delete it.

Also is it good procedure to delete the submenus before deleting the main 
menu item?
Does it matter?

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/ef970c5a-503e-4a55-af10-959c70b1c84en%40googlegroups.com.

Reply via email to