My original plan was to use the standard cmds/pm menus for Maya but I was
recommended to stick with Qt as it ties into the Python ecosystem much
better.

I have the drop down menu set up now but is there much a difference
functionality wise and performance wise if using Qt vs cmds/pm?

On 4 December 2015 at 08:35, Marcus Ottosson <[email protected]> wrote:

> How about the goold ol’ cmds.menu?
>
> import maya.cmds as cmds
>
> cmds.menu( label='MyMenu', tearOff=True, parent='MayaWindow' )
> cmds.menuItem( label='New' )
> cmds.menuItem( label='Open', subMenu=True )
> cmds.menuItem( label='Cheese')
> cmds.menuItem( label='Pasta')
>
>
>    -
>    
> http://help.autodesk.com/cloudhelp/2015/ENU/Maya-Tech-Docs/CommandsPython/menu.html
>
> Qt is great and all, but sometimes the built-in methods aren’t actually
> that bad either.
> ​
>
> On 2 December 2015 at 10:02, Benjam901 <[email protected]> wrote:
>
>> SOLVED:
>>
>> I was defo missing something:
>>
>> this line needed to be changed from returning QWidget to return
>> QMainWindow:
>>
>> return shiboken.wrapInstance(long(ptr), QtGui.QMainWindow)
>>
>>
>> Adding the menu using: mayaWindow.menuBar().addMenu(mainMenu) works well now 
>> :)
>>
>>
>> But in the meantime if anyone has any solid tips to consider while creating 
>> something like this please feel free to post
>>
>>
>> Cheers,
>>
>>
>> Ben
>>
>>
>>
>> On Wednesday, 2 December 2015 10:57:49 UTC+1, Benjam901 wrote:
>>>
>>> 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/e5e17196-fcda-47ad-be89-0a5a5e61427d%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/e5e17196-fcda-47ad-be89-0a5a5e61427d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> *Marcus Ottosson*
> [email protected]
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python_inside_maya/IcMpXXmDnSM/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAe%3DYCT7n%2BrxoxwybELuaGQKLOteZOg_wwOjzLovgid5g%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAe%3DYCT7n%2BrxoxwybELuaGQKLOteZOg_wwOjzLovgid5g%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Tel - +46 76245 92 90 (Sweden)
LinkedIn: http://www.linkedin.com/pub/ben-hearn/50/a64/33b

-- 
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/CAM2ybkXaohCQABj3AQv-aBj1ET7MmEskidpDM1wUB0_Lmb0ZPA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to