我試圖在按下按鈕時生成動畫,但在self.frame2傳回大小0後,它不起作用:
這是一個例子:
幀傳回0後,動畫不會再次執行:from PyQt5.QtWidgets import QMainWindow,QApplication
from PyQt5 import QtCore
from PyQt5 import uic
class Login(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi("1.-Login.ui",self)
#Apariencia de Ventana
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_NoSystemBackground,True)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
#Botones
self.Ajustes.clicked.connect(self.animaAjustes)
self.ComboSuc.lineEdit().setAlignment(QtCore.Qt.AlignCenter)
self.animation = QtCore.QPropertyAnimation(self.frame2, b'size', self)
self.animation.setStartValue(QtCore.QSize(0,0))
self.animation.setEndValue(QtCore.QSize(145,443))
self.animation.setDuration(200)
self.animation.setDirection(QtCore.QAbstractAnimation.Forward)
def animaAjustes(self):
if self.frame2.width()!=0:
self.frame2.setGeometry(0,0,0,0)
else:
self.animation.start()
app = QApplication([])
l = Login()
l.show()
app.exec_()
在檔案.ui在
^{pr2}$