Creating a new menu for Custom Gizmos
I had TONS of trouble trying to figure out how to make a menu, so here is my tutorial. (Keep in mind, this is a tutorial for super ultra mega beginners) Be SURE you read the directories carefully during this tutorial!
What we will do: We will add a new menu to your "Nodes" menu. This will make your custom gizmos easier to access.
First, we need to create some directories and files.
Navigate to Nuke x.x/plugins/ (My directory is: /usr/local/Nuke6.1v3-32/plugins/) (sometimes Nuke x.x is known as .nuke) *
In your "plugins" folder, create a folder called "user", this is where you will keep your menu.py, init.py files for organizing your custom menu.
Enter your new "user" folder, and create a folder called "gizmos", this is where you will keep your gizmos. Then, create a folder called "icons", you can keep your super special awesome cusom menu icons here.
Now that we have our directories, copy your custom gizmos into the "gizmos" folder, and your Custom Menu Icon into your "icons" folder. Don't have one? Here is one that I made: http://i51.tinypic.com/2w6v613_th.png (Remember to rename the image!) Keep in mind: Your menu may not be visable if you do not have an icon.
Now, everything is just about set up. We just need to Create/Edit our init.py and menu.py files, creating a .txt (or any other sort of text file) then naming itmenu.py or init.py will do fine.
What we should have so far:
Open your menu.py file, and type this:
1 2 3 4 5 6 7 8 9 10 |
import sys import nuke print 'Loading Lab Tools...' menubar = nuke.menu("Nuke") # Custom Lab Tools toolbar = nuke.toolbar("Nodes") m = toolbar.addMenu("MENU NAME", icon="MENU ICON.png") |
Lovely, we have created our menu! But our menu does not contain any Gizmos.
To insert a Gizmo into the Menu, type:
1 |
m.addCommand("Example 1", "nuke.createNode(\"Example 2\")", icon="ICON.png") |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import sys import nuke print 'Loading Lab Tools...' menubar = nuke.menu("Nuke") # Custom Lab Tools toolbar = nuke.toolbar("Nodes") m = toolbar.addMenu("CUSTOM MENU 1", icon="ICON NAME HERE.png") m.addCommand("CUSTOMGIZMO", "nuke.createNode(\"CUSTOMGIZMO\")", icon="IMAGE NAME HERE.png") m.addCommand("CUSTOMGIZMO", "nuke.createNode(\"CUSTOMGIZMO\")", icon="IMAGE NAME HERE.png") m.addCommand("CUSTOMGIZMO", "nuke.createNode(\"CUSTOMGIZMO\")", icon="IMAGE NAME HERE.png") # Custom Lab Tools toolbar = nuke.toolbar("Nodes") m = toolbar.addMenu("CUSTOM MENU 2", icon="ICON NAME HERE.png") m.addCommand("CUSTOMGIZMO", "nuke.createNode(\"CUSTOMGIZMO\")", icon="IMAGE NAME HERE.png") m.addCommand("CUSTOMGIZMO", "nuke.createNode(\"CUSTOMGIZMO\")", icon="IMAGE NAME HERE.png") m.addCommand("CUSTOMGIZMO", "nuke.createNode(\"CUSTOMGIZMO\")", icon="IMAGE NAME HERE.png") # Custom Lab Tools toolbar = nuke.toolbar("Nodes") m = toolbar.addMenu("CUSTOM MENU 3", icon="ICON NAME HERE.png") m.addCommand("CUSTOMGIZMO", "nuke.createNode(\"CUSTOMGIZMO\")", icon="IMAGE NAME HERE.png") m.addCommand("CUSTOMGIZMO", "nuke.createNode(\"CUSTOMGIZMO\")", icon="IMAGE NAME HERE.png") m.addCommand("CUSTOMGIZMO", "nuke.createNode(\"CUSTOMGIZMO\")", icon="IMAGE NAME HERE.png") |
Nuke is addicted to init.py files, and will not survive without them.
1 2 3 4 5 6 7 |
# Copyright (c) 2009 The Foundry Visionmongers Ltd. All Rights Reserved. ## init.py ## loaded by nuke before menu.py nuke.pluginAddPath('./gizmos') nuke.pluginAddPath('./icons') |
Comments
Forgive me if I am asking elementary questions but I am just learning Python for the first time.
Just wanted to ask what exactly the first few lines do?
" import sys
import nuke
print 'Loading Lab Tools...'
menubar = nuke.menu("Nuke ")
# Custom Lab Tools "
What do these lines actually do?
Cheers.
J
RSS feed for comments to this post