【发布时间】:2019-03-04 06:23:32
【问题描述】:
我有以下代码,我在其中试图生成一个向左的动画幻灯片并显示以下 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)
【问题讨论】:
标签: python pyqt5 qpropertyanimation