Hey Carl,
What exactly are you trying to do?
What you are doing right now is trying to set False on both a and b knobs,
then set True to the knob you're currently changing (could be any knob,
including trying to move your knob around in the GUI). That is where your
problem is coming from, most of these other knobs aren't expecting a Bool.

if you're just trying to make 2 checkboxes where you can only pick one, I
would suggest using a condition.
Something like that (There is probably an easier way):

n = nuke.createNode('NoOp')

n.addKnob(nuke.Boolean_Knob('a', ' '))

n.addKnob(nuke.Boolean_Knob('b', ' '))

n['knobChanged'].setValue('''

n = nuke.thisNode()

k = nuke.thisKnob()

if k == n['a']:

    n['b'].setValue(False)

    k.setValue(True)

elif k == n['b']:

    n['a'].setValue(False)

    k.setValue(True)

''')



or to keep with mostly your code:


###### code

n = nuke.createNode('NoOp')

n.addKnob(nuke.Boolean_Knob('a', ' '))

n.addKnob(nuke.Boolean_Knob('b', ' '))


n['knobChanged'].setValue('''

print

n = nuke.thisNode()

k = nuke.thisKnob()


for cb in [n['a'],n['b']]:

    cb.setValue(False)

    if k in [n['a'],n['b']]: k.setValue(True)

    print cb.value()

''')

###### /code


Notice that both knobs turn off anytime you touch anything in the knob
though. Depending on what you're making it might or might not be a good
thing.

Hope that helps

Cheers

Erwan






On Tue, Mar 11, 2014 at 4:26 AM, Carl Schröter <ad...@l-rac.de> wrote:

> Hi all,
>
> I came across a strange error message while trying to set values on
> checkboxes via knobChanged.
> The following example works but throws this error: "TypeError: setValue()
> argument 1 must be string or None, not bool"
> Any idea why a boolean knob is not taking a bool value ? When setting a
> bool I also can't deselect or move the node...
> Supplying a str prevents the error message but breaks the code.
>
> ###### code
> n = nuke.createNode('NoOp')
> n.addKnob(nuke.Boolean_Knob('a', ' '))
> n.addKnob(nuke.Boolean_Knob('b', ' '))
>
> n['knobChanged'].setValue('''
> print
> n = nuke.thisNode()
> k = nuke.thisKnob()
>
> for cb in [n['a'],n['b']]:
>     cb.setValue(False)
>     k.setValue(True)
>     print cb.value()
> ''')
> ###### /code
>
> Best,
> Carl
> _______________________________________________
> 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