Sent directly by accident. Re-sending to the mailing list.
You need to have a knob (or know the index of the knob) after which you want to
insert your new knob(s):
# If you have a knob (in a variable `insertAfter`)
popped = []
for i in xrange(node.numKnobs() - 1, -1, -1):
knob = node.knob(i)
if knob is insertAfter:
break
node.removeKnob(knob)
popped.append(knob)
# -- Add your new knobs here --
for knob in popped:
node.addKnob(knob)
Note that if your node has Link_Knob objects on it that you want to pop off and
re-add, this gets a lot uglier, since the only way to find the Link_Knob
objects is to look them up in the node.knobs() dict by name (which doesn’t give
you any positional information). I recommend not crossing that bridge unless
you have to.
In most cases, the best solution is to create your knobs in the proper order to
begin with, and use knob flags and visibility to create dynamic UIs.
-Nathan
From: Torax Unga
Sent: Friday, July 26, 2013 1:18 PM
To: Nathan Rusch ; Nuke Python discussion
Subject: Re: [Nuke-python] Adding a knob in outside last tab
Really? Can you do an example using the code bellow? If you can.
Thanks!
--------------------------------------------------------------------------------
From: Nathan Rusch <[email protected]>
To: Torax Unga <[email protected]>; Nuke Python discussion
<[email protected]>
Sent: Thursday, 25 July 2013, 15:05
Subject: Re: [Nuke-python] Adding a knob in outside last tab
Knobs can only be added at the end of the node’s controls. In order to "insert"
a knob, you have to remove knobs from the node in reverse order until you get
to the correct position, insert your new knob, and then re-add the knobs that
were removed.
-Nathan
From: Torax Unga
Sent: Thursday, July 25, 2013 2:57 PM
To: Nuke Python discussion
Subject: [Nuke-python] Adding a knob in outside last tab
Hi There,
I have created two tabs in a node and I want to add knobs to the first tab
after I created the second one. How can switch the focus to the first tab?
group = nuke.createNode('Group')
with group:
firstab = nuke.Tab_Knob("firsTab","First Tab")
group.addKnob(firstab)
colorkA = nuke.Color_Knob("colorkA", "color A")
group.addKnob(colorkA)
sectab = nuke.Tab_Knob("secTab","Second tab")
group.addKnob(sectab)
colorkB = nuke.Color_Knob("colorkB", "Color B")
group.addKnob(colorkB)
colorkC = nuke.Color_Knob("colorkC", "Color C") #want this in the first
tab
group.addKnob(colorkC)
Cheers!
--------------------------------------------------------------------------------
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python