Hello all,
I am rather stuck trying to add a QMenu to the main Maya window.
The aim is to have a custom menu that acts like the other menus on the top
bar i.e. drop down and sub options appear and inside them various other sub
options etc. etc. but I cannot seem to get my menu to pin up just yet I
think I may be missing something.
I haven't added any functions to execute to it yet, still trying to get it
to show up first
Here is my code:
import shiboken
from PySide import QtGui, QtCore
import maya.OpenMayaUI as apiUI
def getMayaWindow():
ptr = apiUI.MQtUtil.mainWindow()
if ptr is not None:
return shiboken.wrapInstance(long(ptr), QtGui.QWidget)
def addMenuItem(myMenu=None, title='', action=''):
myMenu.addMenu(title)
#menu.addAction(action)
def addSeparator(myMenu):
myMenu.addSeparator()
def setupMenuBar():
print 'setting up menu bar'
mayaWindow = getMayaWindow()
mainMenu = QtGui.QMenu('Overkill_Tools', mayaWindow)
addMenuItem(mainMenu, 'TESTING', lambda: test)
#mayaWindow.menuBar().addMenu(mainMenu)
def test():
print 'testing qt-ness'
setupMenuBar()
Cheers,
Ben
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/bd163a9f-f55d-4954-97ec-a387b300518c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.