Add python scripts to the menubar

Hey guys,

I’m trying to add python scripts to the menubar but I’m getting a "userscripts not defined" type of message when I try to run them. Everything else (gizmos and tcl scripts) works fine.

Here is what I added to my init.py file.

Code:

# add path for user custom files
nuke.pluginAddPath("/Volumes/Macintosh HD/Users/tnt2000/Documents/Nuke6.2v2/")

# add path for user installed .gizmo files
nuke.pluginAddPath("/Volumes/Macintosh HD/Users/tnt2000/Documents/Nuke6.2v2/gizmos")

# add path for user installed .tcl files
nuke.pluginAddPath("/Volumes/Macintosh HD/Users/tnt2000/Documents/Nuke6.2v2/tcl")

# add path for user installed icons
nuke.pluginAddPath("/Volumes/Macintosh HD/Users/tnt2000/Documents/Nuke6.2v2/icons")

# add path for user installed python scripts
sys.path.append("/Volumes/Macintosh HD/Users/tnt2000/Documents/Nuke6.2v2/python")


Here is an example of a python scrip I’m trying to add on my menu.py

Code:

# Add Custom menu for scripts
menubar=nuke.menu("Nodes")
m=menubar.addMenu("&Custom/Scripts")

# Add Python scripts to the custom menu
m.addCommand("Toggle PostageStamp on Read", "userscripts.togglePostageStampOnRead()", icon="PostageStamp.png")


Inside …Documents/Nuke6.2v2/python folder I have a __init.py__ file and a subfolder called "userscripts" which is where I keep all python scripts.

Here is an example for the __init.py__ file

Code:

from togglePostageStampOnRead import *


Do u guys have any idea of what I’m doing wrong? I never added python scripts before… not sure if this is the correct procedure.

Cheers

No Responses to “Add python scripts to the menubar”

Post a Comment