0

I'd like to add an event to change the color of some elements in batches when I click the button in PyQt5. I'd like to change the color to a variable in the setStyleSheet, what should I do?

Below is the way I tried and failed.

setting_btn.setStyleSheet(
    'QPushButton { color: black; background-color:{0}; border-radius: 5px;}'.format('#519AA4'),
    'QPushButton:pressed { background-color: #305F65 }'
)
eyllanesc
  • 221,139
  • 17
  • 121
  • 189
  • change to `'QPushButton {{ color: black; background-color:{0}; border-radius: 5px;}}'.format('#519AA4')` – eyllanesc Jul 21 '21 at 06:10
  • Also, despite the problem in this case was clear to us, generally speaking avoid using forms like "I tried and failed" without providing further description, as they are completely useless to us. Try to find what the error was, if you don't see any, try to execute the program from a terminal or prompt. Remember that you should provide detailed descriptions of your problems. – musicamante Jul 21 '21 at 12:02

0 Answers0