pyblish / pyblish-starter

A basic asset creation pipeline - batteries included. http://pyblish.com/pyblish-starter
MIT License
17 stars 9 forks source link

Fancy menu #1

Open mottosso opened 8 years ago

mottosso commented 8 years ago

Goal

Stand out from traditional menus with larger item, icon, an image of resulting GUI along with a description of what it is for.

Implementation

Generate your own menu and place it amongst other menus.

from maya import cmds
from Qt import QtCore, QtWidgets

cmds.menu("MyMenu", parent="MayaWindow")
widgets = {w.objectName(): w for w in QtWidgets.qApp.allWidgets()}
parent = widgets["MayaWindow"]
menu = widgets["MyMenu"]

def opening(*args):
    widget = QtWidgets.QMenu(parent)
    widget.setTearOffEnabled(True)
    widget.move(menu.pos())
    widget.resize(200, 150)
    widget.show()

menu.aboutToShow.connect(opening)