Add Collapsable Group to Control Panel

In a previous post I showed you how to open and close a group of knobs in a control panel with Python. This little snippet of code shows you how to create a group with a Python script. It was’t as straight forward as I would have liked. For some reason you use the Tab_Knob, even though that sounds like it would create a new tab, and there were several ways to set the begin and end flag.

n = nuke.createNode('NoOp')
# you can use either 1 or nuke.TABBEGINGROUP as the thrid flag
# group = nuke.Tab_Knob('group', 'Group :', nuke.TABBEGINGROUP)
group = nuke.Tab_Knob('group', 'Group :', 1)
knob = nuke.nuke.Boolean_Knob('invert')
# you can use either -1 or nuke.TABENDGROUP as the third flag
# groupEnd = nuke.Tab_Knob('group', 'Group :', nuke.TABENDGROUP)
groupEnd = nuke.Tab_Knob('group', 'Group :', -1)