Oh yes, don't get me wrong. I personally like the fact that a lot in Hiero's API is just passing on QT's structures and functionality. But it's a real disincentive to customise Hiero as it's not exactly straight forward for inexperienced pythonistas, and, worst of all, it's very poorly documented.

Cheers,
frank

On 10/10/16 9:40 PM, Antony Nasce wrote:
Hehe, yeah, I suppose it is a lot for what should be a simple task - just thought I'd give the full Geek-spiel for completeness :)

But it does give a lot of power, and again, avoids ambiguity with actions that can have the same title. (though you're right about needing to be user friendly - perhaps a 'Customising the UI' section needs to be added to the Python Dev Guide, with examples...)

Joerg - I meant to ask, how/where is your 'my menu' action being added?

On 10 October 2016 at 00:40, Frank Rueter|OHUfx <fr...@ohufx.com <mailto:fr...@ohufx.com>> wrote:

    That's a lot of geekism for adding a hotkey to an existing action :-D
    We definitely need to make this more user friendly.



    On 10/08/2016 09:43 PM, Antony Nasce wrote:
    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* <fr...@ohufx.com
        <mailto:fr...@ohufx.com>>
        Date: Fri, Oct 7, 2016 at 6:44 AM
        Subject: Re: [Nuke-python] Nuke Studio assigning Menu Shortcuts
        To: nuke-python@support.thefoundry.co.uk
        <mailto:nuke-python@support.thefoundry.co.uk>


        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 list
        Nuke-python@support.thefoundry.co.uk
        
<mailto:Nuke-python@support.thefoundry.co.uk>,http://forums.thefoundry.co.uk/
        <http://forums.thefoundry.co.uk/>
        http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
        <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>
        _______________________________________________ Nuke-python
        mailing list Nuke-python@support.thefoundry.co.uk
        <mailto:Nuke-python@support.thefoundry.co.uk>,
        http://forums.thefoundry.co.uk/
        <http://forums.thefoundry.co.uk/>
        http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
        <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>

    _______________________________________________
    Nuke-python mailing list
    Nuke-python@support.thefoundry.co.uk
    <mailto:Nuke-python@support.thefoundry.co.uk>,http://forums.thefoundry.co.uk/ 
<http://forums.thefoundry.co.uk/>
    http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
    <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>
    _______________________________________________ Nuke-python
    mailing list Nuke-python@support.thefoundry.co.uk
    <mailto:Nuke-python@support.thefoundry.co.uk>,
    http://forums.thefoundry.co.uk/ <http://forums.thefoundry.co.uk/>
    http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
    <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