thanks heaps Ant! That works like a treat. And good to "talk" to you. Has been a
while ... :)
> Antony Nasce <antonyna...@gmail.com> hat am 11. Oktober 2016 um 12:30
> geschrieben:
>
> Hey Joerg,
>
> Take this Gist
> https://gist.github.com/antiero/2e849923acc24684d8420b2359ecadca for a spin
> and let us know how it goes...
>
> https://gist.github.com/antiero/2e849923acc24684d8420b2359ecadca
>
> (I've tried to #Comment it as much as poss :)
>
> Cheers,
> Ant
>
> -----------------------------------
> from hiero.ui import menuBar, findMenuAction, registerAction
> from PySide import QtGui
>
> # Get the top-level MenuBar
> m = menuBar()
> myMenu = m.addMenu( 'SuperMenu' )
> def doMyThing():
> print "Doing Ma Thing"
>
> myAction = QtGui.QAction ( 'my entry', None )
>
> # We can set a custom object name for the QAction...
> myAction.setObjectName("custom.doMyThing")
>
> # You could set the Keyboard shortcut here...
> myAction.setShortcut("Alt+G")
> myAction.triggered.connect( doMyThing )
> myMenu.addAction( myAction )
>
> # We could register it to the internal actions, so it can be retrieved
> anywhere...
> registerAction(myAction)
>
> # Then maybe retrieve the action from a different file, by finding the
> action like so...
> foundAction = findMenuAction("custom.doMyThing")
>
> # And set a new shortcut here...
> foundAction.setShortcut("Alt+Shift+G")
>
>
>
> On 10 October 2016 at 21:15, Joerg Bruemmer <j.bruem...@lostgraphics.de
> mailto:j.bruem...@lostgraphics.de > wrote:
>
> > >
> > Hey guys,
> >
> > thanks Ant. I tried it briefly yesterday, but had no success. I am
> > adding 2 menu entries my self. I thought I could assign the shortcut while
> > adding, but that did not work as well. That's why I looked into assigning it
> > afterwards. I do the following to add the menu:
> >
> > m = hiero.ui.menuBar()
> > myMenu = m.addMenu( 'SuperMenu' )
> > def doMyThing():
> > execfile( 'some.py' )
> > myAction = QAction ( 'my entry', None )
> > hiero.ui.registerAction ( myAction )
> > myMenu.addAction( myAction )
> > myAction.triggered.connect( doMyThing )
> >
> > Thanks,
> >
> > Joerg
> >
> > > > > Antony Nasce <antonyna...@gmail.com
> > > > > mailto:antonyna...@gmail.com > hat am 10. Oktober 2016 um
> > > > > 21:40 geschrieben:
> > >
> > >
> > > 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
> > > 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
> >
> >
> > >
>
>
> --
> ~~~~~~~~~~~~~~~~~~~
> Antony Nascè,
> Tel: +44 (0) 7793 823444
> _______________________________________________
> 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