Actually, it's alright, it doesn't make sense to add a script to a submenu,
I was just wondering why I was always getting an error.

The main issue that got me looking into that was trying to add a command
directly into the 'Nuke' menu.
nuke.menu('Nuke').addCommand('TestCommand')

I know this isn't very conventional, but we were trying to have a direct
button to do something always visible in the main Menu. The problem with
that is that the newly added command only displays a little part of the
label. Is there a way to get it to display the full label?  menus display
just fine, but commands don't.

Thanks
Erwan

*Erwan* LEROY
www.erwanleroy.com

On Thu, Jul 23, 2015 at 10:06 PM, Erwan Leroy <er...@erwanleroy.com> wrote:

> 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 <
> babak.khat...@thefoundry.co.uk> 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 <er...@erwanleroy.com> 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 <er...@erwanleroy.com>
>>> 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
>>> 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
>>
>>
>
_______________________________________________
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