更改销售时生成幻灯片动画左翼

Generate Slide animation left wing when changing Sales

我有以下代码,我在其中寻求向左生成动画幻灯片并显示以下 QMainWindow 并关闭它在函数中使用 QPropertyAnimation 的当前代码,但它在这里不起作用我离开了代码:

Origin.py

from PyQt5.QtWidgets import QMainWindow,QApplication,QPushButton
from PyQt5 import QtCore
from segunda import MainTwo

class Main(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)


        self.Boton = QPushButton(self)
        self.Boton.setText("Press")
        self.Boton.clicked.connect(self.AnimaFunction)

        self.next = MainTwo()

    def AnimaFunction(self):
        self.anima = QtCore.QPropertyAnimation(self.next.show(),b'geometry')
        self.anima.setDuration(1000)
        self.anima.setStartValue(QtCore.QRect(0,0,0,0))
        self.anima.setEndValue(QtCore.QRect(self.next.geometry()))
        self.anima.start()


app = QApplication([])
m = Main()
m.show()
m.resize(800,600)
app.exec_()

Segunda.py

from PyQt5.QtWidgets import QMainWindow,QApplication,QLabel


class MainTwo(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)


        self.Label = QLabel(self)
        self.Label.setText("Soy la segunda ventana")
        self.Label.resize(200,200)

您必须将 window 传递给 QPropertyAnimation,而不是传递 None 显示方法的 return,因此 QPropertyAnimation不会完成它的工作,考虑到上面的解决方案是:

def AnimaFunction(self):
    self.anima = QtCore.QPropertyAnimation(self.next, b'geometry')
    self.anima.setDuration(1000)
    self.anima.setStartValue(QtCore.QRect(0,0,0,0))
    self.anima.setEndValue(QtCore.QRect(self.next.geometry()))
    self.anima.start()
    self.next.show()
    self.hide()