'Set the current shown widget index.'

def setCurrentIndex(self, index):

    index = max(min(index, (self.count() - 1)), 0)
    if (self.__currentIndex == (-1)):
        self.layout().setCurrentIndex(index)
        self.__currentIndex = index
        return
    current = self.__widgets[self.__currentIndex]
    next_widget = self.__widgets[index]
    def has_pending_resize(widget):
        return (widget.testAttribute(Qt.WA_PendingResizeEvent) or (not widget.testAttribute(Qt.WA_WState_Created)))
    current_pix = next_pix = None
    if (not has_pending_resize(current)):
        current_pix = current.grab()
    if (not has_pending_resize(next_widget)):
        next_pix = next_widget.grab()
    with updates_disabled(self):
        self.__fadeWidget.setPixmap(current_pix)
        self.__fadeWidget.setPixmap2(next_pix)
        self.__nextCurrentIndex = index
        self.__transitionStart()
