[Python] PyQt5 styleSheet Animation

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am using PyQt5 to build an app with multiple buttons. What I am trying to accomplish is to create a blinking background color (yellow-red) for some of my buttons.

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


    The animation starts (it removes the predefined, green background), but it doesn't change the background color of the button to yellow or red.

    Any ideas?

    Continue reading...

Compartilhe esta Página