So, after trying many things, I learned enough to make it work. For anyone
who’s interested, here’s my example code for making a simple UI that switches
tabs, based on a selector… Hopefully, the email mangling won’t wreak havoc on
it.
—————————————————————————————
import nuke
import nukescripts
class TabsDialog(nukescripts.PythonPanel):
def __init__(self):
super(TabsDialog, self ).__init__("Tab Examples")
# Choice section knobs...
self.Choice_BeginGroup = nuke.Text_Knob('choice_BeginGroup',
'NODE_FILTERING:')
self.nodesChoice = nuke.Enumeration_Knob('nodes', 'Nodes: ', ['All',
'Selected'])
self.nodesChoice.setTooltip('Choose to perform action on All nodes or
only the Selected ones.')
self.ClassChoice = nuke.Enumeration_Knob('class', 'Class: ', ['Write',
'Read'])
self.ClassChoice.setTooltip('Choose to perform the action on one Class
of node.')
self.divider = nuke.Text_Knob('')
# WRITE Tab knobs...
self.Write_BeginTabGroup = nuke.Tab_Knob('', 'Write Node Controls')
self.Write_insideKnob = nuke.Int_Knob("insideGroup")
self.Write_inside2Knob = nuke.Int_Knob("also_inside")
# Collector of all the WRITE knobs we make...
self.Write_Collection = [self.Write_BeginTabGroup,
self.Write_insideKnob, self.Write_inside2Knob]
# READ Tab knobs...
self.Read_BeginTabGroup = nuke.Tab_Knob('', 'Read Node Controls')
self.Read_insideKnob = nuke.Int_Knob("insideGroup")
self.Read_inside2Knob = nuke.Int_Knob("also_inside")
# Collector of all the READ knobs we make...
self.Read_Collection = [self.Read_BeginTabGroup, self.Read_insideKnob,
self.Read_inside2Knob]
# Start these knobs as invisible. Only the default ClassChoice
selection starts as visible...
for k in self.Read_Collection:
k.setFlag(nuke.INVISIBLE)
# Add Choice section knobs...
self.addKnob(self.Choice_BeginGroup)
self.addKnob(self.nodesChoice)
self.addKnob(self.ClassChoice)
self.addKnob(self.divider)
# Add WRITE section knobs...
self.addKnob(self.Write_BeginTabGroup)
self.Write_BeginTabGroup.setFlag(nuke.STARTLINE)
self.addKnob(self.Write_insideKnob)
self.addKnob(self.Write_inside2Knob)
# Add READ section knobs...
self.addKnob(self.Read_BeginTabGroup)
self.Read_BeginTabGroup.setFlag(nuke.STARTLINE)
self.addKnob(self.Read_insideKnob)
self.addKnob(self.Read_inside2Knob)
# Dictionary of knob collections...
self.All_Collections_Dict = {"self.Write_Collection":
self.Write_Collection, "self.Read_Collection": self.Read_Collection}
def knobChanged(self, knob):
# Show and hide knodes based on Class of node selected...
if knob == self.ClassChoice:
choice = self.ClassChoice.value()
for collection_name in self.All_Collections_Dict.keys():
if choice in collection_name:
collection = self.All_Collections_Dict.get(collection_name)
for k in collection:
k.clearFlag(nuke.INVISIBLE)
elif choice not in collection_name:
collection = self.All_Collections_Dict.get(collection_name)
for k in collection:
k.setFlag(nuke.INVISIBLE)
elif knob == self.nodesChoice:
pass
TabsDialog().showModalDialog()
—————————————————————————————
Rich
Rich Bobo
Senior VFX Compositor
Armstrong White
Email: [email protected]
http://armstrong-white.com/
Email: [email protected]
Mobile: (248) 840-2665
Web: http://richbobo.com/
"Man does not live by a turkey in every oven or a color TV set in every home.
Man lives by faith and hope and love, by the star on the horizon, by the
trumpet that will not call retreat."
- E. Merrill Root
On Oct 6, 2014, at 5:10 PM, Richard Bobo <[email protected]> wrote:
> Hi,
>
> Bashing my head against opening and closing tab groups…
> Once I’ve created a Tab_Knob with nuke.TABBEGINGROUP and the corresponding
> TABENDGROUP, how do I open and close the tabs via Python? I have tried a
> hundred different ways and I can’t figure it out! There is a nuke.tabClose()
> method — but, no corresponding tabOpen() — and I can’t make it do anything.
> I’ve googled for hours and have given up looking (almost). Any help??
>
> Thanks,
> Rich
>
>
> Rich Bobo
> Senior VFX Compositor
> Armstrong White
> Email: [email protected]
> http://armstrong-white.com/
>
> Email: [email protected]
> Mobile: (248) 840-2665
> Web: http://richbobo.com/
>
> "The nearest way to glory -- a shortcut, as it were -- is to strive to be
> what you wish to be thought to be."
> - Socrates, quoted in Cicero, 44 BC.
>
>
>
>
>
>
>
>
>
> _______________________________________________
> 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