在GitHub尋得一款好看的黑色主題QDarkStyleSheet,界面美觀,放兩張官方的截圖,如下:
使用方法很簡單,代碼如下:
import sys
import qdarkstyle
from PyQt5 import QtWidgets
# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
# setup stylesheet
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
# run
window.show()
app.exec_()
需要注意的是,在使用QDarkStyleSheet後,PyInstaller生成exe時會將PyQt4的相關文件打包,導致exe文件不能正常運行,故需要在spec文件中添加excludes=[‘PyQt4’]。