The nuke.Panel is deprecated in favour of the much more robust/flexible nukescripts.PythonPanel module. You could do something like this, and not have to worry about escaping the values:

class ProjectSelector(nukescripts.PythonPanel):
    def __init__(self, projects):
        nukescripts.PythonPanel.__init__(self)

        self.project = nuke.Enumeration_Knob(
            'project',
            "Name: ",
            projects)
        self.addKnob(self.project)


pl = ['project name 1', 'project name 2', 'project name 3']
p = ProjectSelector(pl)

clicked_ok = p.showModalDialog()
if clicked_ok:
    print p.project.value()
else:
    print "Cancelled..."


(or you could access the value with p.knobs()['project'].value() like you would on any other node)

On 04/03/13 22:34, Victor Perez wrote:
Hi guys,

I'm quite sure somebody answered this before but I cannot find it.

The question is: I'm accessing a DB to get the list of the project names (some 
of them have 2 or more words separated by spaces). When creating the 
enumerationPulldown every time it finds a space it understand it's a new entry 
and split the name of the project in separated entries. Of course I could 
replace the space characters with underscores but would like to know the 
'smart' way and place the names with their spaces on it.

I know that if I place the \ character in the options it will use those 
characters as break lines, but I have no idea how to use this in a proper list.

Here you are an example of the code:

pl = ['project name 1', 'project name 2', 'project name 3']
plstr = ','.join(pl)
strlist = plstr.replace(',', ' ')
print strlist
p = nuke.Panel('Project Name')
p.addEnumerationPulldown('Name: ', strlist)
p.show()

What I'm missing here?

Thanks!

Victor Perez
[email protected]
+44 (0) 7757 199-766

_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

--
ben dickson
2D TD | [email protected]
rising sun pictures | www.rsp.com.au
_______________________________________________
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