def add_actions(target, actions, insert_before=None):
 previous_action = None
 target_actions = list(target.actions())
 if target_actions:
  previous_action = target_actions[(-1)]
  if previous_action.isSeparator():
   previous_action = None
 for action in actions:
  if ((action is None) and (previous_action is not None)):
   if (insert_before is None):
    target.addSeparator()
   else:
    target.insertSeparator(insert_before)
  elif isinstance(action, QMenu):
   if (insert_before is None):
    target.addMenu(action)
   else:
    target.insertMenu(insert_before, action)
  elif isinstance(action, QAction):
   if isinstance(action, SpyderAction):
    if (isinstance(target, QMenu) or (not isinstance(target, QToolBar))):
     action = action.no_icon_action
   if (insert_before is None):
    target.addAction(action)
   else:
    target.insertAction(insert_before, action)
  previous_action = action

def add_actions ( target , actions , insert_before = None ) : previous_action = None target_actions = list ( target . actions ( ) ) if target_actions : previous_action = target_actions [ ( - 1 ) ] if previous_action . isSeparator ( ) : previous_action = None for action in actions : if ( ( action is None ) and ( previous_action is not None ) ) : if ( insert_before is None ) : target . addSeparator ( ) else : target . insertSeparator ( insert_before ) elif isinstance ( action , QMenu ) : if ( insert_before is None ) : target . addMenu ( action ) else : target . insertMenu ( insert_before , action ) elif isinstance ( action , QAction ) : if isinstance ( action , SpyderAction ) : if ( isinstance ( target , QMenu ) or ( not isinstance ( target , QToolBar ) ) ) : action = action . no_icon_action if ( insert_before is None ) : target . addAction ( action ) else : target . insertAction ( insert_before , action ) previous_action = action
add actions to a qmenu or a qtoolbar .