3

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()

アニメーションが開始されます (定義済みの緑の背景が削除されます) が、ボタンの背景色が黄色または赤に変更されることはありません。

何か案は?

4

1 に答える 1