Graphics Programs Reference
In-Depth Information
Under Python, Nuke calls the various panels, panes, and toolboxes “menus.” The Nodes
Toolbar you use all the time to grab nodes from is a menu simply called Nodes under
Python. Here, you will add a new toolbox menu to the Nodes menu and call it User. You
are then going to tell Nuke to place a link to your Gizmo in the new User menu.
Creating a Button with Python
Your first line of code will be to call up the Nodes menu and call it by a name (toolbar),
so that you can easily refer to it in the next lines of code. Calling a command by name is
called assigning a variable in scripting. The Nodes menu will have the variable toolbar
assigned to it.
1. As the first line in your Script Editor's Input pane, enter the following:
toolbar = nuke.menu('Nodes')
2. Click the Run button at the top of the Script Editor to execute this command.
The command you wrote disappears and the following appears in your Output
pane:
toolbar = nuke.menu('Nodes')
# Result:
This means the command executed with no error. Let's make sure the new vari-
able toolbar is now defined.
3. In the Input pane enter toolbar and press the Run button.
The result of this should be something like this:
# Result: <Menu object at 0x15cc80f0>
Keep adding to the script, line after line, so you end up with one long script
containing all the commands you wrote, one after another. You use the Previous
Script button to bring back the previous command to the Input pane.
4. Click the Previous Script button twice to bring back the full toolbar =
nuke.menu('Nodes') command.
Now to create the new menu inside of the newly defined variable toolbar .
5. Press Enter/Return to start a new line and type the next command:
userMenu = toolbar.addMenu('User')
You just created a new menu called “User” with the addMenu command. (In in-
terface terms you made an empty toolbox called User in the Nodes Toolbar.) All
Search WWH ::




Custom Search