This does work indeed. I thought menu objects were a subclass of menuItem
objects, and that it was inheriting setScript.
http://docs.thefoundry.co.uk/nuke/90/pythonreference/nuke.Menu-class.html

So there is no way to attach a script to a menu object directly?

*Erwan* LEROY
www.erwanleroy.com

On Thu, Jul 23, 2015 at 9:55 PM, Babak Khataee <
[email protected]> wrote:

> Hi Erwan!
>
> The setScript/script methods can only be called on menu items, not menus.
> Try the following..
>
> menuItem = nuke.menu('Nuke').addMenu('Test').addCommand("Hi")
>
> menuItem.setScript("execfile('script.py')")
>
>
> hth!
>
>
>
>
>
> On 23 July 2015 at 14:51, Erwan Leroy <[email protected]> wrote:
>
>> Sorry Everyone, I meant setScript()...
>>
>> menu = nuke.menu('Nuke').addMenu('Test')
>>
>> menu.setScript("execfile('script.py')")
>>
>> # Result: Traceback (most recent call last):
>>
>> File "<string>", line 2, in <module>
>>
>> RuntimeError: item is not a script command
>>
>> *Erwan* LEROY
>> www.erwanleroy.com
>>
>> On Thu, Jul 23, 2015 at 12:46 PM, Erwan Leroy <[email protected]>
>> wrote:
>>
>>> Hello,
>>> I was trying to use the toScript() Method listed here:
>>> http://docs.thefoundry.co.uk/nuke/90/pythonreference/nuke.MenuItem-class.html
>>>
>>> Whatever I try to pass as an argument, (including the command listed as
>>> an example in the docs) I get:
>>> RuntimeError: item is not a script command
>>>
>>> I get the same error when using the .script() method.
>>>
>>> I was just exploring the capabilities of this function, so far no luck.
>>> Am I doing something wrong? It seems like it's not accepting strings as an
>>> argument.
>>>
>>> Anyone ever used that method?
>>>
>>>
>>> *Erwan* LEROY
>>> www.erwanleroy.com
>>>
>>
>>
>> _______________________________________________
>> 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