If you check the return value of .Class(), it returns 'Enumeration_Knob'. Since you're in Python, you should grab the actual class object to ensure proper typing.

knobCls = someKnob.__class__
myKnob = knobCls(someKnob.name(), someKnob.label(), someKnob.values())

-Nathan

-----Original Message----- From: Patrick Heinen
Sent: Tuesday, December 04, 2012 11:45 AM
To: nuke-python@support.thefoundry.co.uk
Subject: [Nuke-python] getattr and CascadingEnumeration_Knob

Hey,

I was searching for a way to dynamically create knobs of a type I don't know in advance. What I found is getattr and currently I'm using it like this:

myKnobClass=someKnob.Class()
myName=someKnob.name()
myValues=someKnob.values()
myKnob=getattr(nuke, myKnobClass)(myName,myName,myValues)

this does exactly what I want in the script editor. However I use it in a function in a python panel class (which should then add the knob to that python panel). This works for most knobs aswell. But when creating a CascadingEnumeration_Knob, I don't get the cascading style, but entries with a slash e.g. "FirstCategory/FirstEntry".

I really have no clou why this happens, would be cool if someone has an idea

cheers
Patrick
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to