Hi Nathan,

thanks for your reply!
I guess I had the knobClass hardcoded yesterday when it worked in the script 
editor. You're right the return value is 'Enumeration_Knob'. With .__class__ I 
don't need getattr, that's cool! But I still only get an Enumeration_Knob 
object. Is there any simple way of knowing that it is a 
CascadingEnumeration_Knob? 

thanks
cheers
Patrick

----- Original Message -----
From: [email protected]
To: [email protected]
Date: 04.12.2012 20:56:47
Subject: Re: [Nuke-python] getattr and CascadingEnumeration_Knob


> 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: [email protected]
> 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
> [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

_______________________________________________
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