def METHOD_NAME(self, menu, action, deferShortcut=False):
    """Add action to menu as well as self so that when the menu bar is
    invisible, its actions are still available. If deferShortcut
    is True, set the shortcut context to widget-only, where it
    will avoid conflict with shortcuts already bound to the
    widgets themselves.
    """
    menu.addAction(action)
    self.addAction(action)
    if deferShortcut:
        action.setShortcutContext(qt.Qt.WidgetShortcut)
    else:
        action.setShortcutContext(qt.Qt.ApplicationShortcut)