code: def insertMenuBefore(self, before_menu, new_menu):
          
          if isinstance(before_menu, string_types):
              before_menu = self.findMenu(before_menu)
          before_action = self.actionForMenu(before_menu)
          # I have no clue why QMenuBar::insertMenu only allows
          # to insert before another menu and not after a menu...
          new_action = self.insertMenu(before_action, new_menu)
          return new_action
docs: Insert a menu after another menu in the menubar
  
          @type: before_menu QMenu instance or title string of menu
          @param before_menu: menu which should be after the newly inserted menu
          @rtype: QAction instance
          @return: action for inserted menu