def loginResult(self):
     if self.connected:
         self.bot_thread.started.disconnect()
         self.bot_thread.finished.disconnect()
         bot.signalUserData.connect(self.bot_thread.quit)
         self.bot_thread.started.connect(bot.userData)
         self.bot_thread.finished.connect(LoginDialog.close)
         bot.signalUserData.connect(ui_mw.setUserData)
         LoginDialog.finished.connect(MainWindow.show)
         self.bot_thread.start()
     else:
         self.loginEdit.setText(_fromUtf8(""))
         self.passEdit.setText(_fromUtf8(""))
         self.loginEdit.setEnabled(True)
         self.passEdit.setEnabled(True)
         self.btnLogin.setEnabled(True)
         self.animation = QtCore.QPropertyAnimation(self.label, "geometry")
         self.animation.setDuration(75)
         self.animation.setStartValue(QtCore.QRect(30, 20, 191, 61))
         self.animation.setEndValue(QtCore.QRect(75, 20, 191, 61))
         self.animation1 = QtCore.QPropertyAnimation(self.label, "geometry")
         self.animation1.setDuration(75)
         self.animation1.setStartValue(QtCore.QRect(75, 20, 191, 61))
         self.animation1.setEndValue(QtCore.QRect(35, 20, 191, 61))
         self.animation2 = QtCore.QPropertyAnimation(self.label, "geometry")
         self.animation2.setDuration(75)
         self.animation2.setStartValue(QtCore.QRect(35, 20, 191, 61))
         self.animation2.setEndValue(QtCore.QRect(70, 20, 191, 61))
         self.secuentialAnimation = QtCore.QSequentialAnimationGroup()
         self.secuentialAnimation.addAnimation(self.animation)
         self.secuentialAnimation.addAnimation(self.animation1)
         self.secuentialAnimation.addAnimation(self.animation2)
         self.secuentialAnimation.start()
         self.labelBGSpinner.setVisible(False)
         self.labelSpinner.setVisible(False)
Exemple #2
0
    def _animation_expand(self, value):
        size_animation = qc.QPropertyAnimation(self, 'geometry')
        opacity_anim = qc.QPropertyAnimation(self.main_widget_proxy, 'opacity')

        # Animation Opacity
        opacity_anim.setStartValue(not (value))
        opacity_anim.setEndValue(value)
        opacity_anim.setDuration(200)
        opacity_anim_curve = qc.QEasingCurve()
        if value:
            opacity_anim_curve.setType(qc.QEasingCurve.InQuad)
        else:
            opacity_anim_curve.setType(qc.QEasingCurve.OutQuad)
        opacity_anim.setEasingCurve(opacity_anim_curve)

        # def size of the geometry
        geometry = self.geometry()
        width = geometry.width()
        x, y, _, _ = geometry.getCoords()
        size_start = qc.QRect(x, y, width, int(not (value)) * 150)
        size_end = qc.QRect(x, y, width, int(value) * 150)

        # Animation for geometry
        size_animation.setStartValue(size_start)
        size_animation.setEndValue(size_end)
        size_animation.setDuration(300)
        anim_curve = qc.QEasingCurve()
        if value:
            anim_curve.setType(qc.QEasingCurve.InQuad)
        else:
            anim_curve.setType(qc.QEasingCurve.OutQuad)
        size_animation.setEasingCurve(anim_curve)

        # Animation sequence
        self._animation = qc.QSequentialAnimationGroup()

        if value:
            self.main_widget_proxy.setOpacity(0)
            self._animation.addAnimation(size_animation)
            self._animation.addAnimation(opacity_anim)
            self._animation.finished.connect(self._animation.clear)

        else:
            self.main_widget_proxy.setOpacity(1)
            self._animation.addAnimation(opacity_anim)
            self._animation.addAnimation(size_animation)
            self._animation.finished.connect(self._animation.clear)
            self._animation.finished.connect(self.delete_widget)

        size_animation.valueChanged.connect(self._force_resize)

        self._animation.start(qc.QAbstractAnimation.DeleteWhenStopped)
Exemple #3
0
    def _animateExpand(self, value):
        opacity_anim = qc.QPropertyAnimation(self.main_widget_proxy, "opacity")
        opacity_anim.setStartValue(not(value));
        opacity_anim.setEndValue(value)
        opacity_anim.setDuration(200)
        opacity_anim_curve = qc.QEasingCurve()
        if value is True:
            opacity_anim_curve.setType(qc.QEasingCurve.InQuad)
        else:
            opacity_anim_curve.setType(qc.QEasingCurve.OutQuad)
        opacity_anim.setEasingCurve(opacity_anim_curve)

        size_anim = qc.QPropertyAnimation(self, "geometry")

        geometry = self.geometry()
        width    = geometry.width()
        x, y, _, _ = geometry.getCoords()

        size_start = qc.QRect(x, y, width, int(not(value)) * 150)
        size_end   = qc.QRect(x, y, width, value * 150)

        size_anim.setStartValue(size_start)
        size_anim.setEndValue(size_end)
        size_anim.setDuration(300)

        size_anim_curve = qc.QEasingCurve()
        if value:
            size_anim_curve.setType(qc.QEasingCurve.InQuad)
        else:
            size_anim_curve.setType(qc.QEasingCurve.OutQuad)
        size_anim.setEasingCurve(size_anim_curve)

        self._animation = qc.QSequentialAnimationGroup()
        if value:
            self.main_widget_proxy.setOpacity(0)
            self._animation.addAnimation(size_anim)
            self._animation.addAnimation(opacity_anim)
        else:
            self.main_widget_proxy.setOpacity(1)
            self._animation.addAnimation(opacity_anim)
            self._animation.addAnimation(size_anim)

        size_anim.valueChanged.connect(self._forceResize)
        self._animation.finished.connect(self._animation.clear)

        if not value:
            self._animation.finished.connect(self.deleteWidget)

        self._animation.start(qc.QAbstractAnimation.DeleteWhenStopped)
Exemple #4
0
    def set_state(self, state):
        AbstractActionWidget.set_state(self, state)
        if state.icon:
            self.setPixmap(state.icon.getQPixmap())
            self.resize(self.pixmap().width(), self.pixmap().height())
        if state.notification:
            # Shake animation #
            notificationAnimationPart1 = QtCore.QPropertyAnimation(self, 'pos')
            notificationAnimationPart1.setObjectName(
                'notificationAnimationPart1')
            notificationAnimationPart1.setDuration(50)
            notificationAnimationPart1.setEasingCurve(
                QtCore.QEasingCurve.Linear)

            notificationAnimationPart2 = QtCore.QPropertyAnimation(self, 'pos')
            notificationAnimationPart2.setObjectName(
                'notificationAnimationPart2')
            notificationAnimationPart2.setDuration(50)
            notificationAnimationPart2.setEasingCurve(
                QtCore.QEasingCurve.Linear)

            notificationAnimationPart3 = QtCore.QPropertyAnimation(self, 'pos')
            notificationAnimationPart3.setObjectName(
                'notificationAnimationPart3')
            notificationAnimationPart3.setDuration(50)
            notificationAnimationPart3.setEasingCurve(
                QtCore.QEasingCurve.Linear)

            notificationAnimation = QtCore.QSequentialAnimationGroup(
                parent=self)
            notificationAnimation.setObjectName('notificationAnimation')
            notificationAnimation.setLoopCount(10)
            notificationAnimation.addAnimation(notificationAnimationPart1)
            notificationAnimation.addAnimation(notificationAnimationPart2)
            notificationAnimation.addAnimation(notificationAnimationPart3)

            # Timer is used to simulate a pausing effect of the animation.
            notificationAnimationTimer = QtCore.QTimer(parent=self)
            notificationAnimationTimer.setObjectName(
                'notificationAnimationTimer')
            notificationAnimationTimer.setInterval(1500)
            notificationAnimationTimer.setSingleShot(True)
            notificationAnimationTimer.timeout.connect(
                notificationAnimation.start)
            notificationAnimation.finished.connect(
                notificationAnimationTimer.start)
        self.resetLayout()
Exemple #5
0
def startanimation(parent=None):
    import sys

    app = QtGui.QApplication(sys.argv)

    button1 = QGraphicsRectWidget()
    button2 = QGraphicsRectWidget()
    button3 = QGraphicsRectWidget()
    button4 = QGraphicsRectWidget()
    button2.setZValue(1)
    button3.setZValue(2)
    button4.setZValue(3)

    scene = QtGui.QGraphicsScene(0, 0, SCREENSIZE, SCREENSIZE,parent=parent)
    scene.setBackgroundBrush(QtCore.Qt.black)
    scene.addItem(button1)
    scene.addItem(button2)
    scene.addItem(button3)
    scene.addItem(button4)

    window = QtGui.QGraphicsView(scene,parent=parent)
    window.setFrameStyle(0)
    window.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
    window.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
    window.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

    machine = QtCore.QStateMachine()

    group = QtCore.QState()
    timer = QtCore.QTimer()
    timer.setInterval(1250)
    timer.setSingleShot(True)
    group.entered.connect(timer.start)

    state1 = createGeometryState(button1, QtCore.QRect(BLOCKSIZE*2, 0, BLOCKSIZE, BLOCKSIZE),
            button2, QtCore.QRect(BLOCKSIZE*3, 0, BLOCKSIZE, BLOCKSIZE),
            button3, QtCore.QRect(SCREENSIZE-BLOCKSIZE*2, 0, BLOCKSIZE, BLOCKSIZE),
            button4, QtCore.QRect(SCREENSIZE-BLOCKSIZE, 0, BLOCKSIZE, BLOCKSIZE), group)

    state2 = createGeometryState(button1, QtCore.QRect(SCREENSIZE-BLOCKSIZE,BLOCKSIZE*2, BLOCKSIZE, BLOCKSIZE),
            button2, QtCore.QRect(SCREENSIZE-BLOCKSIZE, BLOCKSIZE*3, BLOCKSIZE, BLOCKSIZE),
            button3, QtCore.QRect(SCREENSIZE-BLOCKSIZE, SCREENSIZE-BLOCKSIZE*2, BLOCKSIZE, BLOCKSIZE),
            button4, QtCore.QRect(SCREENSIZE-BLOCKSIZE, SCREENSIZE-BLOCKSIZE, BLOCKSIZE, BLOCKSIZE), group)

    state3 = createGeometryState(button1, QtCore.QRect(BLOCKSIZE*3, SCREENSIZE-BLOCKSIZE, BLOCKSIZE, BLOCKSIZE),
            button2, QtCore.QRect(BLOCKSIZE*2, SCREENSIZE-BLOCKSIZE, BLOCKSIZE, BLOCKSIZE),
            button3, QtCore.QRect(BLOCKSIZE, SCREENSIZE-BLOCKSIZE, BLOCKSIZE, BLOCKSIZE),
            button4, QtCore.QRect(0, SCREENSIZE-BLOCKSIZE, BLOCKSIZE, BLOCKSIZE), group)

    state4 = createGeometryState(button1, QtCore.QRect(0, BLOCKSIZE*3, BLOCKSIZE, BLOCKSIZE),
            button2, QtCore.QRect(0, BLOCKSIZE*2, BLOCKSIZE, BLOCKSIZE),
            button3, QtCore.QRect(0, BLOCKSIZE, BLOCKSIZE, BLOCKSIZE),
            button4, QtCore.QRect(0, 0, BLOCKSIZE, BLOCKSIZE), group)

    state5 = createGeometryState(button1, QtCore.QRect( BLOCKSIZE*2,BLOCKSIZE*2, BLOCKSIZE, BLOCKSIZE),
            button2, QtCore.QRect(BLOCKSIZE*3, BLOCKSIZE*2, BLOCKSIZE, BLOCKSIZE),
            button3, QtCore.QRect(BLOCKSIZE*2, BLOCKSIZE*3, BLOCKSIZE, BLOCKSIZE),
            button4, QtCore.QRect(BLOCKSIZE*3, BLOCKSIZE*3, BLOCKSIZE, BLOCKSIZE), group)

    state6 = createGeometryState(button1, QtCore.QRect(BLOCKSIZE, BLOCKSIZE, BLOCKSIZE, BLOCKSIZE),
            button2, QtCore.QRect(SCREENSIZE-2*BLOCKSIZE, BLOCKSIZE, BLOCKSIZE,BLOCKSIZE),
            button3, QtCore.QRect(BLOCKSIZE, SCREENSIZE-2*BLOCKSIZE, BLOCKSIZE, BLOCKSIZE),
            button4, QtCore.QRect(SCREENSIZE-2*BLOCKSIZE, SCREENSIZE-2*BLOCKSIZE, BLOCKSIZE, BLOCKSIZE), group)

    state7 = createGeometryState(button1, QtCore.QRect(0, 0, BLOCKSIZE, BLOCKSIZE),
            button2, QtCore.QRect(SCREENSIZE-BLOCKSIZE, 0, BLOCKSIZE, BLOCKSIZE),
            button3, QtCore.QRect(0, SCREENSIZE-BLOCKSIZE, BLOCKSIZE, BLOCKSIZE),
            button4, QtCore.QRect(SCREENSIZE-BLOCKSIZE, SCREENSIZE-BLOCKSIZE, BLOCKSIZE, BLOCKSIZE), group)

    group.setInitialState(state1)

    animationGroup = QtCore.QParallelAnimationGroup()
    anim = QtCore.QPropertyAnimation(button4, 'geometry')
    anim.setDuration(1000)
    anim.setEasingCurve(QtCore.QEasingCurve.OutElastic)
    animationGroup.addAnimation(anim)

    subGroup = QtCore.QSequentialAnimationGroup(animationGroup)
    subGroup.addPause(100)
    anim = QtCore.QPropertyAnimation(button3, 'geometry')
    anim.setDuration(1000)
    anim.setEasingCurve(QtCore.QEasingCurve.OutElastic)
    subGroup.addAnimation(anim)

    subGroup = QtCore.QSequentialAnimationGroup(animationGroup)
    subGroup.addPause(150)
    anim = QtCore.QPropertyAnimation(button2, 'geometry')
    anim.setDuration(1000)
    anim.setEasingCurve(QtCore.QEasingCurve.OutElastic)
    subGroup.addAnimation(anim)

    subGroup = QtCore.QSequentialAnimationGroup(animationGroup)
    subGroup.addPause(200)
    anim = QtCore.QPropertyAnimation(button1, 'geometry')
    anim.setDuration(1000)
    anim.setEasingCurve(QtCore.QEasingCurve.OutElastic)
    subGroup.addAnimation(anim)

    stateSwitcher = StateSwitcher(machine)
    group.addTransition(timer.timeout, stateSwitcher)
    stateSwitcher.addState(state1, animationGroup)
    stateSwitcher.addState(state2, animationGroup)
    stateSwitcher.addState(state3, animationGroup)
    stateSwitcher.addState(state4, animationGroup)
    stateSwitcher.addState(state5, animationGroup)
    stateSwitcher.addState(state6, animationGroup)
    stateSwitcher.addState(state7, animationGroup)

    machine.addState(group)
    machine.setInitialState(group)
    machine.start()

    window.resize(SCREENSIZE, SCREENSIZE)
    window.show()

    
    sys.exit(app.exec_())
Exemple #6
0
    state3.assignProperty(p2, 'pos', QtCore.QPointF(0, 5 + 64 + 5))
    state3.assignProperty(p3, 'pos', QtCore.QPointF(5, 5 + (64 + 5) + 64))
    state3.assignProperty(p4, 'pos', QtCore.QPointF(5 + 64 + 5, 5))
    state3.assignProperty(p5, 'pos', QtCore.QPointF(5 + 64 + 5, 5 + 64 + 5))
    state3.assignProperty(p6, 'pos', QtCore.QPointF(5 + 64 + 5, 5 + (64 + 5) + 64))
    state3.assignProperty(widget, 'geometry', QtCore.QRectF(138, 5, 400 - 138, 200))
    state3.assignProperty(box, 'geometry', QtCore.QRect(5, 205, 400, 90))
    state3.assignProperty(p1, 'opacity', 1.0)
    state3.assignProperty(p2, 'opacity', 1.0)
    state3.assignProperty(p3, 'opacity', 1.0)
    state3.assignProperty(p4, 'opacity', 1.0)
    state3.assignProperty(p5, 'opacity', 1.0)
    state3.assignProperty(p6, 'opacity', 1.0)

    t1 = state1.addTransition(button.clicked, state2)
    animation1SubGroup = QtCore.QSequentialAnimationGroup()
    animation1SubGroup.addPause(250)
    animation1SubGroup.addAnimation(QtCore.QPropertyAnimation(box, 'geometry', state1))
    t1.addAnimation(animation1SubGroup)
    t1.addAnimation(QtCore.QPropertyAnimation(widget, 'geometry', state1))
    t1.addAnimation(QtCore.QPropertyAnimation(p1, 'pos', state1))
    t1.addAnimation(QtCore.QPropertyAnimation(p2, 'pos', state1))
    t1.addAnimation(QtCore.QPropertyAnimation(p3, 'pos', state1))
    t1.addAnimation(QtCore.QPropertyAnimation(p4, 'pos', state1))
    t1.addAnimation(QtCore.QPropertyAnimation(p5, 'pos', state1))
    t1.addAnimation(QtCore.QPropertyAnimation(p6, 'pos', state1))
    t1.addAnimation(QtCore.QPropertyAnimation(p1, 'rotation', state1))
    t1.addAnimation(QtCore.QPropertyAnimation(p2, 'rotation', state1))
    t1.addAnimation(QtCore.QPropertyAnimation(p3, 'rotation', state1))
    t1.addAnimation(QtCore.QPropertyAnimation(p4, 'rotation', state1))
    t1.addAnimation(QtCore.QPropertyAnimation(p5, 'rotation', state1))
Exemple #7
0
    def __init__(self, action, gui_context, parent):
        QtGui.QLabel.__init__(self, parent)
        AbstractActionWidget.__init__(self, action, gui_context)

        self.setObjectName('ActionButton')
        self.setMouseTracking(True)

        # This property holds if this button reacts to mouse events.
        self.interactive = False

        # This property is used to store the original position of this label
        # so it can be visually reset when the user leaves before the ongoing
        # animation has finished.
        self.originalPosition = None

        # This property holds the state of the selection animation. Since this
        # animation is only created inside startSelectionAnimation() (to avoid
        # the increasing amount of performAction() invocations), this variable is
        # used to continuously store the state of that animation.
        self.selectionAnimationState = QtCore.QAbstractAnimation.Stopped
        self.setMaximumHeight(160)

        opacityEffect = QtGui.QGraphicsOpacityEffect(parent=self)
        opacityEffect.setOpacity(1.0)
        self.setGraphicsEffect(opacityEffect)

        # Bounce animation #
        hoverAnimationPart1 = QtCore.QPropertyAnimation(self, 'pos')
        hoverAnimationPart1.setObjectName('hoverAnimationPart1')
        hoverAnimationPart1.setDuration(500)
        hoverAnimationPart1.setEasingCurve(QtCore.QEasingCurve.Linear)

        hoverAnimationPart2 = QtCore.QPropertyAnimation(self, 'pos')
        hoverAnimationPart2.setObjectName('hoverAnimationPart2')
        hoverAnimationPart2.setDuration(1500)
        hoverAnimationPart2.setEasingCurve(QtCore.QEasingCurve.OutElastic)

        hoverAnimation = QtCore.QSequentialAnimationGroup(parent=self)
        hoverAnimation.setObjectName('hoverAnimation')
        hoverAnimation.setLoopCount(-1)  # Infinite
        hoverAnimation.addAnimation(hoverAnimationPart1)
        hoverAnimation.addAnimation(hoverAnimationPart2)
        ####################

        # Selection animation #
        selectionAnimationPart1 = QtCore.QPropertyAnimation(self, 'pos')
        selectionAnimationPart1.setObjectName('selectionAnimationPart1')
        selectionAnimationPart1.setDuration(200)
        selectionAnimationPart1.setEasingCurve(QtCore.QEasingCurve.Linear)

        selectionAnimationPart2 = QtCore.QPropertyAnimation(self, 'size')
        selectionAnimationPart2.setObjectName('selectionAnimationPart2')
        selectionAnimationPart2.setDuration(200)
        selectionAnimationPart2.setEasingCurve(QtCore.QEasingCurve.OutCubic)

        selectionAnimationPart3 = QtCore.QPropertyAnimation(
            self.graphicsEffect(), 'opacity')
        selectionAnimationPart3.setObjectName('selectionAnimationPart3')
        selectionAnimationPart3.setDuration(200)
        selectionAnimationPart3.setEasingCurve(QtCore.QEasingCurve.Linear)

        selectionAnimation = QtCore.QParallelAnimationGroup(parent=self)
        selectionAnimation.setObjectName('selectionAnimation')
        selectionAnimation.addAnimation(selectionAnimationPart1)
        selectionAnimation.addAnimation(selectionAnimationPart2)
        selectionAnimation.addAnimation(selectionAnimationPart3)
        # Not working when clicking the white area underneath the ActionButton image.
        #selectionAnimation.finished.connect(self.resetLayout)
        #selectionAnimation.finished.connect(self.performAction)
        selectionAnimation.stateChanged.connect(
            self.updateSelectionAnimationState)
Exemple #8
0
                                 QtCore.QRect(200, 200, 50, 50), group)

    state7 = createGeometryState(button1, QtCore.QRect(0, 0, 50, 50), button2,
                                 QtCore.QRect(250, 0, 50, 50), button3,
                                 QtCore.QRect(0, 250, 50, 50), button4,
                                 QtCore.QRect(250, 250, 50, 50), group)

    group.setInitialState(state1)

    animationGroup = QtCore.QParallelAnimationGroup()
    anim = QtCore.QPropertyAnimation(button4, 'geometry')
    anim.setDuration(1000)
    anim.setEasingCurve(QtCore.QEasingCurve.OutElastic)
    animationGroup.addAnimation(anim)

    subGroup = QtCore.QSequentialAnimationGroup(animationGroup)
    subGroup.addPause(100)
    anim = QtCore.QPropertyAnimation(button3, 'geometry')
    anim.setDuration(1000)
    anim.setEasingCurve(QtCore.QEasingCurve.OutElastic)
    subGroup.addAnimation(anim)

    subGroup = QtCore.QSequentialAnimationGroup(animationGroup)
    subGroup.addPause(150)
    anim = QtCore.QPropertyAnimation(button2, 'geometry')
    anim.setDuration(1000)
    anim.setEasingCurve(QtCore.QEasingCurve.OutElastic)
    subGroup.addAnimation(anim)

    subGroup = QtCore.QSequentialAnimationGroup(animationGroup)
    subGroup.addPause(200)
Exemple #9
0
    def __init__(self, parent=None):
        QtGui.QGraphicsScene.__init__(self, parent)
        #set the size of the scene
        self.setSceneRect(0, 0, 2000, 2000)

        button = QtGui.QPushButton('info')
        button.setMinimumSize(QtCore.QSize(50, 30))
        button.setMaximumSize(QtCore.QSize(50, 30))
        buttonProxy = QtGui.QGraphicsProxyWidget()
        buttonProxy.setWidget(button)

        box = QtGui.QGroupBox()
        box.setStyleSheet(
            "QGroupBox {background: transparent; border: 2px solid black;color: black; background-color: rgba(20%, 30%, 30%, 30%); margin: 1px; padding: 5px;} QGroupBox:Title{background:transparent; margin-top:5px; margin-left:5px;}"
        )
        box.setTitle("C'est la vie.")

        box_child = QtGui.QGroupBox(box)
        box_child.setTitle('Bonjourno')
        box_child.setObjectName('childGroupBox')
        box_child.setStyleSheet(
            "QGroupBox#childGroupBox {background: transparent; border: 2px solid black;color: black; background-color: rgba(10%, 30%, 10%, 30%); margin: 1px; padding: 5px;} QGroupBox:Title#childGroupBox{background:transparent; margin-top:5px; margin-left:5px;}"
        )

        layout2 = QtGui.QVBoxLayout()
        box.setLayout(layout2)
        layout2.addStretch()

        boxProxy = QtGui.QGraphicsProxyWidget()
        boxProxy.setWidget(box)

        # Parent widget.
        widget = QtGui.QGraphicsWidget()
        layout = QtGui.QGraphicsLinearLayout(QtCore.Qt.Vertical, widget)
        layout.addItem(buttonProxy)
        widget.setLayout(layout)

        #QGraphics Scene

        # scene = QtGui.QGraphicsScene(0, 0, 400, 300)
        # scene.setBackgroundBrush(scene.palette().window())
        # scene.addItem(widget)
        # scene.addItem(boxProxy)

        self.setBackgroundBrush(self.palette().window())
        self.addItem(widget)
        self.addItem(boxProxy)

        machine = QtCore.QStateMachine()
        state1 = QtCore.QState(machine)
        state2 = QtCore.QState(machine)
        machine.setInitialState(state1)

        # State 1.
        state1.assignProperty(widget, 'geometry',
                              QtCore.QRectF(0, 0, 400, 150))
        state1.assignProperty(box, 'geometry',
                              QtCore.QRect(-400, 50, 350, 150))
        state1.assignProperty(box_child, 'geometry',
                              QtCore.QRect(30, 300, 150, 100))
        state1.assignProperty(boxProxy, 'opacity', 1.0)

        # State 2.
        state2.assignProperty(widget, 'geometry',
                              QtCore.QRectF(0, 0, 400, 150))
        state2.assignProperty(box, 'geometry', QtCore.QRect(10, 50, 350, 150))
        state2.assignProperty(box_child, 'geometry',
                              QtCore.QRect(30, 30, 150, 100))
        state2.assignProperty(boxProxy, 'opacity', 1.0)

        t1 = state1.addTransition(button.clicked, state2)
        animation1SubGroup = QtCore.QSequentialAnimationGroup()
        animation1SubGroup.addPause(150)
        animation1SubGroup.addAnimation(
            QtCore.QPropertyAnimation(box, 'geometry', state1))

        animation1SubGroup_2 = QtCore.QSequentialAnimationGroup()
        animation1SubGroup_2.addPause(600)
        animation1SubGroup_2.addAnimation(
            QtCore.QPropertyAnimation(box_child, 'geometry', state1))

        t1.addAnimation(animation1SubGroup)
        t1.addAnimation(animation1SubGroup_2)
        t1.addAnimation(QtCore.QPropertyAnimation(widget, 'geometry', state1))

        t2 = state2.addTransition(button.clicked, state1)
        animation1SubGroup_3 = QtCore.QSequentialAnimationGroup()
        animation1SubGroup_3.addPause(300)
        animation1SubGroup_3.addAnimation(
            QtCore.QPropertyAnimation(box_child, 'geometry', state2))
        t2.addAnimation(QtCore.QPropertyAnimation(box, 'geometry', state2))
        t2.addAnimation(animation1SubGroup_3)
        t2.addAnimation(QtCore.QPropertyAnimation(widget, 'geometry', state2))

        machine.start()