Skip to content

Instantly share code, notes, and snippets.

@antiero
Created October 10, 2016 23:27
Show Gist options
  • Save antiero/2e849923acc24684d8420b2359ecadca to your computer and use it in GitHub Desktop.
Save antiero/2e849923acc24684d8420b2359ecadca to your computer and use it in GitHub Desktop.
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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment