0

我正在尝试在 NUKE 中创建一个下拉列表以列出路径中的所有文件夹。到目前为止,这是我的代码:

p = nuke.Panel('my custom panel')
p.addEnumerationPulldown('my choices', (os.walk('E:').next()[1]))
ret = p.show()

我遇到的一个问题是,如果我有一个带有空格的文件夹名称,它会显示为不同的选择。
例如,该文件夹System Test显示为两个选项SystemTest

我怎样才能解决这个问题?

4

1 回答 1

2

The nuke.Panel enumeration pulldown cannot handle strings in the values. You would have to replace any spaces with another character(s) and then create the pulldown.

p = nuke.Panel('my custom panel')
paths = [i.replace(" ", "-_-") for i in os.walk('E:').next()[1]]
p.addEnumerationPulldown('my choices', paths)
ret = p.show()

Ultimately, it's probably better to use a PythonPanel instead if it can fit your needs. It can handle spaces in an Enumeration_Knob attached to the panel.

import os
import nuke
import nukescripts

p = nukescripts.PythonPanel("foo")
k = nuke.Enumeration_Knob("bar", 'bar', os.walk('E:').next()[1])
p.addKnob(k) 
p.show()
于 2013-09-23T05:11:28.773 回答