Skip to content

Instantly share code, notes, and snippets.

@draconiansolo
Last active February 17, 2021 14:52
Show Gist options
  • Save draconiansolo/6744801 to your computer and use it in GitHub Desktop.
Save draconiansolo/6744801 to your computer and use it in GitHub Desktop.
Self-contained nuke knobChanged callbacks...To be able to add a callback when knobs change on a group or gizmo without having to create init callback scripts on the menu.py and stuff.So it is waaay better to do it like this for copypastas :D
#based on http://forums.thefoundry.co.uk/phpBB2/viewtopic.php?t=3602&sid=7c140135632c783e7147e0e1b577eaa6
#which is most interesting...
#code="""
print 'knobChanged fired...'
n=nuke.thisNode()
k=nuke.thisKnob()
if k.name()=='number':
print 'yyyay!!!!!'
#"""
#node['knobChanged'].setValue(code)
#node['help'].setValue( "Help me, I'm in hell!!!!" )
#####################################alternatively#################################:
nuke.selectedNode()['knobChanged'].setValue("""
###your code here
n = nuke.thisNode()
k = nuke.thisKnob()
if k.name() == "p_a":
n['p_b'].setValue(k.value())
elif k.name() == "p_b":
n['p_a'].setValue(k.value())
""")
@bhamid79
Copy link

hi, this might be a stupid question, but where does the code below "##alternatively###" line go.
Does the code in a PyScript knob on the node? in the menu.py file? Having a hard time getting the code to run in the appropriate place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment