Python nuke.menu() Examples

The following are 21 code examples of nuke.menu(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module nuke , or try the search function .
Example #1
Source File: menu.py    From NukeToolSet with MIT License 6 votes vote down vote up
def create_tools(self, menu, type, name, command, shortcut, icon_name):
        """
        create menu tools
        :param type:
        :param menu:
        :param name:
        :param command:
        :param shortcut:
        :param icon:
        :return:
        """
        if type == "python":
            menu.addCommand(name, command, shortcut, icon=icon_name)
        elif type == "gizmo":
            menu.addCommand(name, "nuke.createNode(\"%s\")" % command, icon=icon_name)
        elif type == "toolbar":
            menu.addCommand(name, icon=icon_name) 
Example #2
Source File: interop.py    From P4VFX with MIT License 5 votes vote down vote up
def initializeMenu(self, entries):
        m = nuke.menu( 'Nuke' )
        self.menu = m.addMenu( 'Perforce' ) 
Example #3
Source File: cryptomatte_utilities.py    From Cryptomatte with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _troubleshoot_gizmo(gizmo):
    MSG_WRONGTYPE = 'Troubleshooting: Cannot troubleshoot non-Cryptomatte nodes'
    MSG_UNCONNECTED = 'Cryptomatte gizmo is not plugged into anything'
    MSG_NONE_FOUND = 'No Cryptomattes found in input. '
    MSG_LYR_UNSET = ('Gizmo needs updating, layer is not set. '
                     'Press "force update" or reconnect.')
    MSG_LYR_UNPOP = ('Gizmo needs updating, layer menu is not populated. '
                     'Press "force update" or reconnect.')
    MSG_ODD_STATE = ('Gizmo is in an odd state and needs updating. '
                     'Press "force update" or reconnect.')
    MSG_INVALID_SEL = ('Layer is set to "%s", which is unavailable. '
                       'Select another layer.')
    if gizmo.Class() != "Cryptomatte":
        return [MSG_WRONGTYPE]

    issues = []
    if not gizmo.input(0):
        issues.append(MSG_UNCONNECTED)
    else:
        cinfo = CryptomatteInfo(gizmo, reload_metadata=True)
        available = cinfo.get_cryptomatte_names()
        selection = gizmo.knob('cryptoLayer').value()
        menu_selection = gizmo.knob('cryptoLayerChoice').value()
        if not cinfo.cryptomattes:
            issues.append(MSG_NONE_FOUND)
        else:
            if not selection or not menu_selection:
                issues.append(MSG_LYR_UNSET)
            if menu_selection not in available:
                issues.append(MSG_LYR_UNPOP)
            elif selection not in gizmo.knob(GIZMO_CHANNEL_KNOBS[0]).value():
                issues.append(MSG_ODD_STATE)
            elif selection not in available:
                issues.append(MSG_INVALID_SEL % selection)
    return issues 
Example #4
Source File: cryptomatte_utilities.py    From Cryptomatte with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def setup_cryptomatte_ui():
    if nuke.GUI:
        toolbar = nuke.menu("Nodes")
        menu = toolbar.addMenu("Cryptomatte", "cryptomatte_logo.png",index=-1)
        menu.addCommand("Cryptomatte", "import cryptomatte_utilities as cu; cu.cryptomatte_create_gizmo();")
        menu.addCommand("Decryptomatte All", "import cryptomatte_utilities as cu; cu.decryptomatte_all();")
        menu.addCommand("Decryptomatte Selection", "import cryptomatte_utilities as cu; cu.decryptomatte_selected();")
        menu.addCommand("Encryptomatte", "import cryptomatte_utilities as cu; cu.encryptomatte_create_gizmo();") 
Example #5
Source File: interop.py    From P4VFX with MIT License 5 votes vote down vote up
def addMenuCommand(self, label, iconPath, command):
        self.menu.addCommand(label, command, icon=self.sanitizeIconPath(iconPath)) 
Example #6
Source File: interop.py    From P4VFX with MIT License 5 votes vote down vote up
def addMenuSubmenu(self, label, iconPath, entries):
        # Save our current menu
        parent = self.menu
        self.menu = parent.addMenu(label, icon=self.sanitizeIconPath(iconPath))

        # Fill up the submenu
        self.fillMenu(entries)

        # Reset our current menu
        self.menu = parent 
Example #7
Source File: interop.py    From P4VFX with MIT License 5 votes vote down vote up
def addMenuLabel(self, label):
        tmp = self.menu.addCommand(label, lambda: None)
        tmp.setEnabled(False) 
Example #8
Source File: interop.py    From P4VFX with MIT License 5 votes vote down vote up
def addMenuDivider(self, label):
        self.menu.addSeparator() 
Example #9
Source File: interop.py    From P4VFX with MIT License 5 votes vote down vote up
def addMenuCommand(self, label, iconPath, command):
        self.menu.addCommand(label, command, icon=self.sanitizeIconPath(iconPath)) 
Example #10
Source File: interop.py    From P4VFX with MIT License 5 votes vote down vote up
def addMenuSubmenu(self, label, iconPath, entries):
        # Save our current menu
        parent = self.menu
        self.menu = parent.addMenu(label, icon=self.sanitizeIconPath(iconPath))

        # Fill up the submenu
        self.fillMenu(entries)

        # Reset our current menu
        self.menu = parent 
Example #11
Source File: interop.py    From P4VFX with MIT License 5 votes vote down vote up
def addMenuLabel(self, label):
        tmp = self.menu.addCommand(label, lambda: None)
        tmp.setEnabled(False) 
Example #12
Source File: interop.py    From P4VFX with MIT License 5 votes vote down vote up
def addMenuDivider(self, label):
        self.menu.addSeparator() 
Example #13
Source File: pipeline.py    From core with MIT License 5 votes vote down vote up
def uninstall():
    """Uninstall all that was previously installed

    This is where you undo everything that was done in `install()`.
    That means, removing menus, deregistering families and  data
    and everything. It should be as though `install()` was never run,
    because odds are calling this function means the user is interested
    in re-installing shortly afterwards. If, for example, he has been
    modifying the menu or registered families.

    """

    _uninstall_menu()

    pyblish.deregister_host("nuke") 
Example #14
Source File: menu.py    From NukeToolSet with MIT License 5 votes vote down vote up
def add_menu_tools(self):
        """
        add_menu_tools
        :return:
        """
        menubar = nuke.menu("Nuke")
        toolMenu = menubar.addMenu('&Tools')
        toolMenu_config = self.config["toolMenu"]
        for tools in toolMenu_config:
            self.create_menu_tools(toolMenu,
                                   toolMenu_config[tools]["name"],
                                   toolMenu_config[tools]["command"]
                                   ) 
Example #15
Source File: menu.py    From NukeToolSet with MIT License 5 votes vote down vote up
def add_bar_tools(self):
        """
        add nuke menu tools
        :return:
        """
        toolbar_config = self.config["toolbar"]
        for menus in toolbar_config:
            # first create tool menu
            menu_icon_name = toolbar_config[menus]['icon']
            cmenu = self.create_menu(menus, menu_icon_name)
            list = toolbar_config[menus]['list']
            for tools in list:
                # second add menu list
                if tools["icon"]:
                    tools_icon = tools["icon"]
                else:
                    tools_icon = ""

                print tools_icon
                self.create_tools(cmenu,
                                  tools["type"],
                                  tools["name"],
                                  tools["command"],
                                  tools["shortcut"],
                                  tools_icon
                                  ) 
Example #16
Source File: menu.py    From NukeToolSet with MIT License 5 votes vote down vote up
def create_menu(self, name, icon_name):
        """
        create nuke menu
        :param name:
        :param icon:
        :return:
        """
        tool_bar = nuke.menu('Nodes')
        menu = tool_bar.addMenu(name, icon=icon_name)
        return menu 
Example #17
Source File: applications.py    From hotbox_designer with BSD 3-Clause Clear License 5 votes vote down vote up
def create_menus(self):
        import nuke
        nuke_menu = nuke.menu('Nuke')
        menu = nuke_menu.addMenu('Hotbox Designer')
        hotkey_data = self.load_hotkey()
        for name, value in hotkey_data.items():
            menu.addCommand(
                name='Hotboxes/{name}'.format(name=name),
                command=str(value['command']), shortcut=value['sequence']) 
Example #18
Source File: nodes.py    From dpa-pipe with MIT License 5 votes vote down vote up
def add_commands():

    nuke.menu('Nodes').addCommand(
        name='Image/WriteProduct',
        command=create_write_product_node,
        shortcut='w',
    )

    nuke.menu('Nodes').addCommand(
        name='Image/ReadSub',
        command=create_read_sub_node,
    )

# ----------------------------------------------------------------------------- 
Example #19
Source File: pipeline.py    From core with MIT License 5 votes vote down vote up
def _on_task_changed(*args):

    # Update menu
    _uninstall_menu()
    _install_menu()


# Backwards compatibility 
Example #20
Source File: pipeline.py    From core with MIT License 5 votes vote down vote up
def _uninstall_menu():
    """Uninstalling Avalon menu to Nuke
    """
    menubar = nuke.menu("Nuke")
    menubar.removeItem(api.Session["AVALON_LABEL"]) 
Example #21
Source File: pipeline.py    From core with MIT License 4 votes vote down vote up
def _install_menu():
    """Installing Avalon menu to Nuke
    """
    from ..tools import (
        creator,
        publish,
        workfiles,
        loader,
        sceneinventory
    )

    # Create menu
    menubar = nuke.menu("Nuke")
    menu = menubar.addMenu(api.Session["AVALON_LABEL"])

    label = "{0}, {1}".format(
        api.Session["AVALON_ASSET"], api.Session["AVALON_TASK"]
    )
    context_action = menu.addCommand(label)
    context_action.setEnabled(False)

    menu.addSeparator()
    menu.addCommand("Create...",
                    lambda: creator.show(parent=get_main_window()))
    menu.addCommand("Load...",
                    lambda: loader.show(parent=get_main_window(),
                                        use_context=True))
    menu.addCommand("Publish...",
                    lambda: publish.show(parent=get_main_window()))
    menu.addCommand("Manage...",
                    lambda: sceneinventory.show(parent=get_main_window()))

    menu.addSeparator()
    menu.addCommand("Work Files...",
                    lambda: workfiles.show(
                        os.environ["AVALON_WORKDIR"],
                        parent=get_main_window())
                    )

    menu.addSeparator()
    menu.addCommand("Reset Frame Range", command.reset_frame_range)
    menu.addCommand("Reset Resolution", command.reset_resolution)

    # add reload pipeline only in debug mode
    if bool(os.getenv("NUKE_DEBUG")):
        menu.addSeparator()
        menu.addCommand("Reload Pipeline", reload_pipeline)