I don’t think there’s a particularly elegant solution to this. The cleanest way 
may be something like:

n = nuke.thisNode()
k = nuke.thisKnob()
if k == n['blahh']:
    hide = not k.value()
    opKnobs = ('yeah', 'yeahhh', 'yeeaahhh') # ...etc.
    for kName in opKnobs:
        n[kName].setVisible(hide)

Obviously you could cut out the tuple variable assignment and just run the for 
loop directly on the tuple itself, but if you’ve got dozens, that would get 
messy.

The other option that’s fairly similar is to store the names of the knobs in 
another hidden knob on the Gizmo, but that’s not very clean either.

-Nathan



From: Michael Garrett 
Sent: Wednesday, November 02, 2011 12:16 PM
To: Nuke Python discussion 
Subject: [Nuke-python] For loop for knobChanged

I'm dusting the cobwebs off my nascent python ability and I'd like to know if 
there is a smart way of affecting many gizmo knobs with one knobChanged 
callback without explicitly listing them all.

So, right now I have something like this which is some code to hide some knob 
values in the UI with a toggle switch:

      c=nuke.toNode("Group3")


      code='''

      k=nuke.thisKnob()

      n=nuke.thisNode()

      if k.name()=="blahh":

      n['yeah'].setVisible(k.value()==False)

      n['yeahhh'].setVisible(k.value()==False)

      #etc....


      '''

      c.knob('knobChanged').setValue(code)
     

...where I'm affecting two knob values, but if I had dozens there, can I do a 
'for' loop or something?

Also, is there a python way of toggle expand/collapsing the triangle widget of 
a group knob?

Thanks,
Michael



--------------------------------------------------------------------------------
_______________________________________________
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

Reply via email to