我试图在按下按钮时生成动画,但在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_()
萧十郎
相关分类