def METHOD_NAME(groups, actions, controls=None):
    texts = [str(action.text()) for action in actions]
    if controls:
        controls = dict([('widget-' + z, v) for z, v in controls.items()])
    METHOD_NAME = QToolBar('Toolbar')
    for name, actionlist in groups:
        for action in actionlist:
            if action in texts:
                METHOD_NAME.addAction(actions[texts.index(action)])
            elif action in controls:
                METHOD_NAME.addWidget(controls[action])
        METHOD_NAME.addSeparator()
    return METHOD_NAME