For pulldown menus 3 main methods are used – getValue(), value() and values() as well as setValue() method:
getValue()
g = nuke.toNode('Transform1')['filter'].getValue()
print(g)
# getValue() method brings properties' index (because it's enumerator)
# If your filter="Notch" getValue() brings 7.0 – i.e. eight element
# Result: 7.0
value()
v = nuke.toNode('Transform1')['filter'].value()
print(v)
# value() method brings a name of a chosen filter
# Result: Notch
值()
vv = nuke.toNode('Merge1')['bbox'].values()
print(vv)
# values() method brings a list of all strings stored in enum
# Result: ['union', 'intersection', 'A', 'B']
setValue()
s1 = nuke.toNode('Merge2')['operation'].setValue(0)
# setValue() method sets a new existing value in enum with index 0
# Result: atop
s2 = nuke.toNode('Merge3')['operation'].setValue("xor")
# setValue() method sets a new existing value in enum with name "xor"
# Result: xor
虽然在某些情况下,
getValue()
和value()
是可互换的,但是对于字符串,您必须使用value()
方法,对于数字使用getValue()
方法。在getValue()
给您带来一个数字(枚举所选对的索引)value()
会给您带来一个字符串(枚举所选对的名称)values()
为您提供所有字符串的列表(所有名称)setValue()
为旋钮设置一个新值(您可以在这里使用索引或名称)要打印所选节点的所有旋钮名称和相应值,请使用以下方法:
^{pr2}$getValue()
value()
值()
setValue()
答案很简单,只需使用.value()而不是.getValue(),然后它将返回字符串而不是整数。在
感谢tk421storm
相关问题 更多 >
编程相关推荐