Search code examples
pyqtstylesheet

PyQt : give a color to all the textof an application


I would like to change the look of my application in PyQt. I want all the text (in the buttons, labels and such) to be white for exampel, and all the buttons to be a certain color. Can I change that all at once in the mainWindow ?

I did the following to change the background color of the whole app:

self.setStyleSheet("QMainWindow {background-color: #252526; color: #FFFFFF}")

If I set another stylesheet for the QPushButton for example in the same manner, the style for the QMainWindow will be overridden.


Solution

  • You could call the setStyleSheet() method on your QApplication instance and specify all object names in the CSS string:

    app = QtGui.QApplication.instance()
    app.setStyleSheet('QLabel{color: #fff;} QPushButton{background-color: #000; color: #fff}')