Thanks for your replys! However, If I'm not mistaken none of those methods
will actually pass the values from my panel to the function. In other
words, I can't print the value of the checkbox in my print_value function.
Maybe I'm doing this in a complete different way than I'm supposed to? I've
seen it be done with using knobChanged commands, but this seems much
cleaner. Any other suggestions? Thanks a lot.



2012/11/30 Nathan Rusch <[email protected]>

>   Assuming all you need to do is show the panel, just bind the whole call
> to your menu item at once:
>
> menu.addCommand(‘Show the Panel’, ‘testscript.test_panel().show()’)
>
>
> -Nathan
>
>
>  *From:* Kristopher Young <[email protected]>
> *Sent:* Thursday, November 29, 2012 10:43 AM
> *To:* Nuke Python discussion <[email protected]>
> *Subject:* Re: [Nuke-python] Pyhon panels and functions
>
> Hi again,
>
> forgive me for bringing this thread up again. I've searched for an answer,
> but I just haven't been able to find one. Using the technique Nathan posted
> above, everything works perfectly if I run the script in the script editor.
> But what about if I wanted to add it to a menu in Nuke. Normally I just
> wrap a function around all of my code and in my menu.py I call
> testscript.testfunction(). But now the code where I show the panel isn't
> inside a specific function, it lives in the "root" of the script. I guess
> this is basic Python, but I would really appreciate your help on this.
> Thanks a lot!
>
>  class test_panel(nukescripts.PythonPanel):
>     def __init__(self):
>         nukescripts.PythonPanel.__init__(self, "test panel")
>         self.check = nuke.Boolean_Knob("checkbox", "checkbox")
>         self.addKnob(self.check)
>         self.button = nuke.PyScript_Knob("button", "button")
>         self.addKnob(self.button)
>         self.button.setValue("print_value()")
>
> p = test_panel()
> p.show()
>
> def print_value():
>
>     if p.check.value() == True:
>         print "It's true."
>     else:
>         print "It's not true."
>
>
>
> 2012/11/11 Kristopher Young <[email protected]>
>
>> Thanks for that example Nathan. I will try to read up a bit on Python
>> classes. This is one of my first expreciences with panels so it's a bit
>> hard to grab at the moment. Thanks a lot for your help.
>>
>>
>> 2012/11/11 Nathan Rusch <[email protected]>
>>
>>>   test_panel is your panel class. Since 'check' is defined in __init__,
>>> it doesn’t exist until you create an instance of the class. I recommend
>>> reading up a bit on Python classes.
>>>
>>> p = test_panel()
>>> p.show()
>>>
>>> def print_value():
>>>     if p.check.value():
>>>         print "It's true"
>>>      else:
>>>         print "It's not true"
>>>
>>> Hope this helps
>>>
>>> -Nathan
>>>
>>>
>>>  *From:* Kristopher Young <[email protected]>
>>> *Sent:* Sunday, November 11, 2012 9:52 AM
>>> *To:* Nuke Python discussion <[email protected]>
>>> *Subject:* Re: [Nuke-python] Pyhon panels and functions
>>>
>>>  Hi Howard, I tried your suggestion but it returns "type object
>>> 'test_panel' has no attribute 'check". Any idea? I tried with
>>> test_panel["check"].value() but that didn't work either.
>>>
>>>
>>>
>>> 2012/11/11 Howard Jones <[email protected]>
>>>
>>>> I'm not the best at this by any stretch but isn't it
>>>>
>>>> def print_value():
>>>>
>>>>    if test_panel.check.value() == True:
>>>>        print "It's true."
>>>>    else:
>>>>        print "It's not true."
>>>> ____________________________________
>>>>
>>>> Howard
>>>>
>>>> On 11 Nov 2012, at 09:28, Kristopher Young <[email protected]>
>>>> wrote:
>>>>
>>>> > def print_value():
>>>> >
>>>> >    if self.check.value() == True:
>>>> >        print "It's true."
>>>> >    else:
>>>> >        print "It's not true."
>>>> > ____________________________________
>>>> _______________________________________________
>>>> 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
>>>
>>> _______________________________________________
>>> 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
>
>
> _______________________________________________
> 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