开发者

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 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜