How to add a Group Knob in nuke using python api
<p>Using tcl script in nuke, adding a group knob to a node looks like this</p>

<pre><code>addUserKnob {20 start_group l "My Group" n 1}
... add other knobs
addUserKnob {20 end_group l endGroup n -1}
</code></pre>

<p>It appears that the Group knob uses the same knob type as the Tab knob, except that it uses the <code>n</code> keyword argument. I don't see any information in the <a href="https://www.thefoundry.co.uk/products/nuke/developers/100/pythonreference/nuke.Tab_Knob-class.html" rel="nofollow">python api documentation</a> on how to set the <code>n</code> argument so that nuke creates a Group instead of a Tab.</p>

<p>My python code looks something like this</p>

<pre><code># Get node
node = nuke.toNode('MyNode')

# Add new tab to node
tab = nuke.Tab_Knob('custom_tab', 'Custom Tab')
node.addKnob(tab)

# Add a group knob
group = nuke.Tab_Knob('group_1', 'Group 1')  # some other argument or flag?
node.addKnob(group)

# Add some other knobs
name = nuke.String_Knob('name', 'Name')
node.addKnob(name)

# Add some type of "end group" knob?
?
</code></pre>

<p>I'm assuming I should be using the <code>Tab_Knob</code> in python just like I use the Tab knob type (i.e. <code>20</code>) in tcl script, and that there is both a start and end knob for the group, but I'm not sure how that should be done in python.</p>

<p>Here is how you add Group knobs using python in nuke.</p>

<pre><code>node = nuke.toNode('MyNode')

# A Group node is created by passing a 3rd argument to the Tab Knob

# This will create a Group knob that is open by default
begin = nuke.Tab_Knob('begin', 'My Group :', 1)

# Alternatively, if you want to create a Group knob that is closed by 
# default, you can pass this constant in as the 3rd argument instead
# of 1
begin = nuke.Tab_Knob('begin', 'My Group :', nuke.TABBEGINCLOSEDGROUP)

# Add Group knob to node
node.addKnob(begin)

# Create and add some other knobs.  They will be inside the group.
button1 = nuke.PyScript_Knob("button1", "Button 1")
button2 = nuke.PyScript_Knob("button2", "Button 2")
button3 = nuke.PyScript_Knob("button3", "Button 3")
node.addKnob(button1)
node.addKnob(button2)
node.addKnob(button3)

# Create and add a Close group knob
begin = nuke.Tab_Knob('begin', 'My Group :', -1)
</code></pre>

python nuke