How do you know the color of the view?
-
How to compare color.
QLabel
crgb(45,45,45)
?from PyQt5.Qt import * from PyQt5.QtWebEngineWidgets import * import sys
class Window(QWidget):
def init(self, parent=None):
QWidget.init(self, parent)
self.label = QLabel(self)
self.label.setStyleSheet("background-color: rgb(45,45,45)")
#If цвет self.label == rgb(45,45,45):
print("1")if name == "main":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
-
to the question of how to get a colour https://ru.stackoverflow.com/questions/1345278/%D0%9A%D0%B0%D0%BA-%D0%BF%D1%80%D0%BE%D1%87%D0%B8%D1%82%D0%B0%D1%82%D1%8C-%D1%82%D0%B5%D0%BA%D1%83%D1%89%D0%B8%D0%B5-%D1%86%D0%B2%D0%B5%D1%82%D0%B0-qpalette-%D1%8D%D0%BB%D0%B5%D0%BC%D0%B5%D0%BD%D1%82%D0%B0-qapplication-%D0%B2-pyqt5/1345287#1345287
Comparison of the colour obtained as follows
palette = self.label.palette() color = palette.color(QPalette.Window) if color == QColor(45,45,45): print('equal') else: print('not equal')