通常,PyQt4中的所有应用程序都默认为灰色。工具栏,菜单栏,状态栏,标题栏默认为灰色。是否可以将其更改为其他颜色而不是灰色。我知道它依赖于运行它的操作系统,但PyQt是否允许这样做?
答案 0 :(得分:1)
PyQt允许使用CSS。
from PyQt4 import QtCore as core
from PyQt4 import QtGui as gui
import sys
if '__main__' == __name__:
app = gui.QApplication(sys.argv)
CSS = """
QMainWindow{
background-color: yellow;
}
"""
window_1 = gui.QMainWindow(None)
window_1.setFixedSize(300, 300)
window_1.show()
window_2 = gui.QMainWindow(None)
window_2.setFixedSize(300, 300)
window_2.show()
# Uncomment next line to make all windows yellow
# app.setStyleSheet(CSS)
# Uncomment next line to make all just window_1 yellow
# window_1.setStyleSheet(CSS)
sys.exit(app.exec_())