开发者

PyQt : give a color to all the textof an application

开发者 https://www.devze.com 2023-03-17 13:29 出处:网络
I would like to change the look of my application in PyQt. I want all the text (in the butto开发者_如何学Cns, labels and such) to be white for exampel, and all the buttons to be a certain color.

I would like to change the look of my application in PyQt. I want all the text (in the butto开发者_如何学Cns, 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.


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}')
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号