Working with menus

Working effectively with Maya's menu system involves marrying Maya UI commands with PySide to get the best of both worlds. Maya's menus are an abstraction of standard Qt widgets, and we should use that same abstraction, through UI commands, rather than creating our own. However, we may still want to work with the controls in more sophisticated ways than Maya allows, requiring us access to the actual Qt object.

For the next few sections, we'll create a way to highlight menu items as new until the first time they are clicked.

Creating a top-level menu

Maya's UI commands work just like its other commands. A UI object is represented by a pipe-delimited hierarchical path, such as 'MayaWindow|DemoMenu|menuItem254'. When we use a command ...

Get Practical Maya Programming with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.