Hi.
I can't seem to reproduce the error on nuke 7 (I'm assuming you're using
nuke 8 since I don't seem to have a node called Text2).

Maybe the value of an enumeration knob in nuke 8 would be returned as an
int, so maybe using if key == 1 would work? That's the only type error I
could see here..

I tried your code almost similarly but changing from Text2 to Text and it
worked fine:

n = nuke.createNode("Text")

knob = nuke.Enumeration_Knob("test", "test", ["1", "2"])
n.addKnob(knob)
def knob_callback():
    node = nuke.thisNode()
    knob = nuke.thisKnob()

    knob_name = knob.name()
    if knob_name == "test":
        key = knob.value()
        if key == "1":
            node["font"].setValue("path1")
        else:
            node["font"].setValue("path2")

nuke.addKnobChanged(knob_callback, nodeClass=n.Class())
n["test"].setValue(2)

On 13 Feb 2014 03:50, "Wakisaka,Taku,MARZA" <[email protected]> wrote:

> Hi,
>
> I am having trouble setting Text2's font knob from callback,
> and it gives out following error:
>
> Traceback (most recent call last):
>   File "C:/Program Files/Nuke8.0v3/plugins\nuke\callbacks.py", line 127,
> in knobChanged
>     _doCallbacks(knobChangeds)
>   File "C:/Program Files/Nuke8.0v3/plugins\nuke\callbacks.py", line 44, in
> _doCallbacks
>     for f in list:
> TypeError: an integer is required
>
> Following is a code that reproduce the error:
> n = nuke.createNode("Text2")
>
> knob = nuke.Enumeration_Knob("test", "test", ["1", "2"])
> n.addKnob(knob)
>
> def knob_callback():
>     node = nuke.thisNode()
>     knob = nuke.thisKnob()
>
>     knob_name = knob.name()
>     if knob_name == "test":
>         key = knob.value()
>         if key == "1":
>             node["font"].setValue("Utopia", "Regular")
>         else:
>             node["font"].setValue("Courier", "Regular")
>
> nuke.addKnobChanged(knob_callback, nodeClass=n.Class())
> n["test"].setValue(2)
>
>
> Does anyone know why python is raising TypeError?
> I've never seen a error like this in a for statement.
>
> Thanks,
> Taku
>
>
> _______________________________________________
> 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