def updateSelection(self):
        originalSelection = self._selected

        i = self.getComponentIterator()
        while True:
            try:
                component = i.next()
                tab = self._tabs.get(component)
                # If we have no selection, if the current selection is
                # invisible or if the current selection is disabled (but
                # the whole component is not) we select this tab instead
                selectedTabInfo = None
                if self._selected is not None:
                    selectedTabInfo = self._tabs.get(self._selected)

                if (self._selected is None
                        or selectedTabInfo is None
                        or not selectedTabInfo.isVisible()
                        or not selectedTabInfo.isEnabled()):
                    # The current selection is not valid so we need to
                    # change it
                    if tab.isEnabled() and tab.isVisible():
                        self._selected = component
                        break
                    else:
                        # The current selection is not valid but this
                        # tab cannot be selected either.
                        self._selected = None
            except StopIteration:
                break

        return originalSelection != self._selected
Checks if the current selection is valid, and updates the selection
dataset/ETHPy150Open rwl/muntjac/muntjac/ui/tab_sheet.py/TabSheet.updateSelection