小编Eil*_*lat的帖子

PyQt5 styleSheet 动画

我正在使用 PyQt5 构建一个带有多个按钮的应用程序。我想要完成的是为我的一些按钮创建一个闪烁的背景颜色(黄红色)。

btn1.setStyleSheet("background-color: green; color: red; font-weight: 800; font-size: 22")
tobyte = 'styleSheet'
a = bytearray(tobyte, 'utf-8')
animation = QtCore.QPropertyAnimation(' + 'btn' + str(yy) + ', a)
animation.setDuration(1000)
animation.setLoopCount(1000)
animation.setStartValue("background-color: yellow; color: red; font-weight: 800; font-size: 22")
animation.setEndValue("background-color: red; color: red; font-weight: 800; font-size: 22")
animation.start()
Run Code Online (Sandbox Code Playgroud)

动画开始(删除预定义的绿色背景),但不会将按钮的背景颜色更改为黄色或红色。

有任何想法吗?

python qt pyqt pyqt5 qpropertyanimation

2
推荐指数
1
解决办法
7621
查看次数

标签 统计

pyqt ×1

pyqt5 ×1

python ×1

qpropertyanimation ×1

qt ×1