I want to add a knob to a node, but i want to make sure that it is always shows inside a specific tab.
let's pretend that target node has two tabs, 'A', and 'B' that were created long ago.
target_node = nuke.thisKnob()
taget_node.addKnob(extra_knob)
how can i make extra_knob be created in tab 'A' instead of 'B'?
when i open the .nk file in a text editor knobs seem to have an index, but i can't find anything of the sort in the documentation
Not sure if this is still relevant, but providing an answer to hopefully help others that come across this.
Controlling the order of user knobs is the only way to really guarantee that they show up correctly on the panel. node.allKnobs()
will return the a node's knobs in the order you see them specified in the .nk
file. You can use the "User" tab knob as a separator for where user knobs begin (You shouldn't try to edit the order of non-user knobs). Any nodes you want added to a tab just need to be added after that tab knob.
Here's an example taking an existing node, reordering the knobs into tabs:
node = nuke.selectedNode()
# Find out where the "User Tab" is, this is the start of user knobs
user_knob_index = 35
user_knob = node.knob(user_knob_index)
user_knobs = node.allKnobs()[(user_knob_index + 1):]
# Clear out all the user knobs
for knob in user_knobs:
node.removeKnob(knob)
color_knobs = [i for i in user_knobs if 'color' in i.name()]
di_knobs = [i for i in user_knobs if 'di' in i.name()]
# Create new tab knobs
color_tab = nuke.Tab_Knob('color')
di_tab = nuke.Tab_Knob('di')
# Add the color tab and color knobs
node.addKnob(color_tab)
for knob in color_knobs:
node.addKnob(knob)
# Add the di tab and di knobs
node.addKnob(di_tab)
for knob in di_knobs:
node.addKnob(knob)