I have such a problem with Stylesheet. I have three "lamps" displaying the status of the program, they are made from QPushButton in QT Designer. The program flashes these "lamps" during the action. I did the flashing using the setStyleSheet command, where I prescribed the same thing as originally on the button, but changed the color. But after a while, the program refuses to use stylesheet and the whole program turns into something incomprehensible (see screenshots, the "lamps" I'm talking about are located on the top left).I need to fix it somehow, probably use some other command instead of setStyleSheet.
Initially, the program looks like this:After a time, like this:
In init:
self.stylesheet_blue = u"background-color: rgb(85, 170, 255);\n""border-radius: 6px; \n""border: 0.5px solid;" self.stylesheet_green = u"background-color: rgb(0, 255, 0);\n""border-radius: 6px; \n""border: 0.5px solid;" self.stylesheet_lamp = u"QPushButton { background-color: rgb(255, 255, 255); border-radius: 6px; border: 0.5px solid }" self.stylesheet_red = u"QPushButton { background-color: rgb(255, 0, 0); border-radius: 6px; border: 0.5px solid }"
In my function it looks like this:
while not self.stop_thread: self.lamp1.setStyleSheet(self.stylesheet_blue) if ..... == ....: self.lamp1.setStyleSheet(self.stylesheet_lamp) self.label.setText(capitalized_text +' ('+ str(self.ping(start_time)) +')') self.lamp2.setStyleSheet(self.stylesheet_green) sleep(0.6) self.lamp2.setStyleSheet(self.stylesheet_lamp) if .... == ....: self.lamp3.setStyleSheet(self.stylesheet_red) self.lamp1.setStyleSheet(self.stylesheet_lamp) sleep(0.6) self.lamp3.setStyleSheet(self.stylesheet_lamp)