def addItemBefore(self, caption, icon, command, itemToAddBefore):
        """Add an item before some item. If the given item does not exist the
        item is added at the end of the menu. Icon and command can be null,
        but a caption must be given.

        @param caption:
                   the text for the menu item
        @param icon:
                   the icon for the menu item
        @param command:
                   the command for the menu item
        @param itemToAddBefore:
                   the item that will be after the new item
        @raise ValueError:
        """
        if caption is None:
            raise ValueError, 'caption cannot be null'

        newItem = MenuItem(caption, icon, command, self)

        if itemToAddBefore in self._menuItems:
            try:
                index = self._menuItems.index(itemToAddBefore)
            except __HOLE__:
                index = -1
            self._menuItems.insert(index, newItem)
        else:
            self._menuItems.append(newItem)

        self.requestRepaint()

        return newItem
dataset/ETHPy150Open rwl/muntjac/muntjac/ui/menu_bar.py/MenuBar.addItemBefore