def replaceComponent(self, oldComponent, newComponent):
        if self._selected == oldComponent:
            # keep selection w/o selectedTabChange event
            self._selected = newComponent

        newTab = self._tabs.get(newComponent)
        oldTab = self._tabs.get(oldComponent)

        # Gets the captions
        oldCaption = None
        oldIcon = None
        newCaption = None
        newIcon = None

        if oldTab is not None:
            oldCaption = oldTab.getCaption()
            oldIcon = oldTab.getIcon()

        if newTab is not None:
            newCaption = newTab.getCaption()
            newIcon = newTab.getIcon()
        else:
            newCaption = newComponent.getCaption()
            newIcon = newComponent.getIcon()

        # Gets the locations
        oldLocation = -1
        newLocation = -1
        location = 0
        for component in self._components:
            if component == oldComponent:
                oldLocation = location
            if component == newComponent:
                newLocation = location
            location += 1

        if oldLocation == -1:
            self.addComponent(newComponent)
        elif newLocation == -1:
            self.removeComponent(oldComponent)
            self._keyMapper.remove(oldComponent)
            newTab = self.addTab(newComponent)
            self._components.remove(newComponent)
            self._components.append(oldLocation, newComponent)
            newTab.setCaption(oldCaption)
            newTab.setIcon(oldIcon)
        else:
            if oldLocation > newLocation:
                self._components.remove(oldComponent)
                self._components.append(newLocation, oldComponent)
                self._components.remove(newComponent)
                self._components.append(oldLocation, newComponent)
            else:
                self._components.remove(newComponent)
                self._components.append(oldLocation, newComponent)
                self._components.remove(oldComponent)
                self._components.append(newLocation, oldComponent)

            if newTab is not None:
                # This should always be true
                newTab.setCaption(oldCaption)
                newTab.setIcon(oldIcon)

            if oldTab is not None:
                # This should always be true
                oldTab.setCaption(newCaption)
                oldTab.setIcon(newIcon)

            self.requestRepaint()
Replaces a component (tab content) with another. This can be used
dataset/ETHPy150Open rwl/muntjac/muntjac/ui/tab_sheet.py/TabSheet.replaceComponent