Hey Joerg,
Firstly, might've been a typo, but it should be:
from *hiero.ui* import findMenuAction
(not hiero.core)
Next, one of the nice things about findMenuAction is that it can find
actions by the QAction's objectName, rather than just the action title.
This is useful to avoid ambiguity, when you have actions with the same name
for instance, e.g. 'Timeline' in the Workspace menu, and 'Timeline' on the
top level menu bar.
Here's the help on findMenuAction:
------------------------------------
"findMenuAction(name)
Find a QAction in the main menubar. The 'name' parameter specifies the name
of the action.
The name may be either an internal action name or a display name. e.g.
'Cut', or (better) 'foundry.application.cut'."
------------------------------------
So the recommended way to use findMenuAction is to find via the action's
objectName (if its been set!)
If you run the code below you'll see how the objectNames for the top level
menubar actions appear internally:
M = hiero.ui.menuBar()
for act in M.actions():
objectName = act.objectName()
if objectName:
print act.objectName()
(Note, to retrieve the actual QMenu object for these top level menu
actions, you need to call act.*menu()* on them)
You can set an action's objectName via:
action.setObjectName('my.amazing.action')
Then findMenuAction can work with this objectName:
findMenuAction('my.amazing.action')
Another nice thing to do if you want to retrieve an action and use it
somewhere is to register it internally, via hiero.ui.registerAction( action
)
You can then retrieve it using hiero.ui.findRegisteredAction
I hope this helps, let us know how you get on!
Cheers,
Ant
> ---------- Forwarded message ----------
> From: Frank Rueter|OHUfx <[email protected]>
> Date: Fri, Oct 7, 2016 at 6:44 AM
> Subject: Re: [Nuke-python] Nuke Studio assigning Menu Shortcuts
> To: [email protected]
>
>
> Wasn't there this weird issue where you had to put everything into the
> edit menu as well if you want the hotkey to work?
> Try that and see if it works.
>
>
>
> On 10/07/2016 05:46 PM, Joerg Bruemmer wrote:
>
> Hey guys,
> what am I doing wrong here:
>
> from hiero.core import findMenuAction
> from PySide import QtGui
>
> menuItem = findMenuAction('my menu')
> menuItem.setShortcut(QtGui.QKeySequence('Alt+G'))
>
> I have that in my StartupUi folder as .py, but it does not get picked up.
> Running it in script editor in UI works though.
>
> Thanks,
> Joerg
>
>
> _______________________________________________
> Nuke-python mailing [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