import sys
from maya import cmds
from avalon.vendor.Qt import QtWidgets, QtCore

self = sys.modules[__name__]
self._menu = "polly"


def install():
    from . import interactive

    uninstall()

    def deferred():
        cmds.menu(self._menu,
                  label="Polly",
                  tearOff=True,
                  parent="MayaWindow")

        # Modeling sub-menu
        cmds.menuItem("Modeling",
                      label="Modeling",
                      tearOff=True,
                      subMenu=True,
                      parent=self._menu)

        cmds.menuItem("Combine", command=interactive.combine)

        # Rigging sub-menu
        cmds.menuItem("Rigging",
                      label="Rigging",
                      tearOff=True,
                      subMenu=True,
                      parent=self._menu)

        cmds.menuItem("Auto Connect", command=interactive.auto_connect)
        cmds.menuItem("Clone (Local)", command=interactive.clone_localspace)
        cmds.menuItem("Clone (World)", command=interactive.clone_worldspace)
        cmds.menuItem("Clone (Special)", command=interactive.clone_special)
        cmds.menuItem("Create Follicle", command=interactive.follicle)

        # Animation sub-menu
        cmds.menuItem("Animation",
                      label="Animation",
                      tearOff=True,
                      subMenu=True,
                      parent=self._menu)

        cmds.menuItem("Set Defaults", command=interactive.set_defaults)

        cmds.setParent("..", menu=True)

        cmds.menuItem(divider=True)

        cmds.menuItem("Auto Connect", command=interactive.auto_connect_assets)

    # Allow time for uninstallation to finish.
    QtCore.QTimer.singleShot(100, deferred)


def uninstall():
    app = QtWidgets.QApplication.instance()
    widgets = dict((w.objectName(), w) for w in app.allWidgets())
    menu = widgets.get(self._menu)

    if menu:
        menu.deleteLater()
        del(menu)

@@ -25,16 +25,40 @@
 ort cmds
+%0A%0Afrom avalon import api
 %0Afrom av
@@ -82,19 +82,8 @@
 port
- QtWidgets,
  QtC
@@ -133,14 +133,36 @@
 u = 
-%22polly
+api.session%5B%22label%22%5D + %22menu
 %22%0A%0A%0A
@@ -211,25 +211,8 @@
 ve%0A%0A
-    uninstall()%0A%0A
     
@@ -239,29 +239,33 @@
     
-cmds.menu(self._
+# Append to Avalon's 
 menu
-,
 %0A   
@@ -273,102 +273,34 @@
     
-          label=%22Polly%22,%0A                  tearOff=True,%0A                  parent=%22MayaWindow%22
+cmds.menuItem(divider=True
 )%0A%0A 
@@ -1694,9 +1694,9 @@
 hot(
-1
+2
 00, 
@@ -1732,204 +1732,9 @@
     
-app = QtWidgets.QApplication.instance()%0A    widgets = dict((w.objectName(), w) for w in app.allWidgets())%0A    menu = widgets.get(self._menu)%0A%0A    if menu:%0A        menu.deleteLater()%0A        del(menu)
+pass
 %0A

Implement support for AVALON_LABEL