例如,this page声称PyQt5的最新版本应为我提供macOS Mojave的自动暗模式,而无需改变我的任何东西……除非它没有。
考虑以下简单示例(可以复制粘贴到终端中):
exec("""\nfrom PyQt5 import QtCore, QtWidgets\n\nclass Ui_MainWindow(object):\n def setupUi(self, MainWindow):\n MainWindow.setObjectName("MainWindow")\n MainWindow.resize(674, 371)\n self.centralwidget = QtWidgets.QWidget(MainWindow)\n self.centralwidget.setObjectName("centralwidget")\n self.gridLayoutWidget = QtWidgets.QWidget(self.centralwidget)\n self.gridLayoutWidget.setGeometry(QtCore.QRect(50, 10, 601, 281))\n self.gridLayoutWidget.setObjectName("gridLayoutWidget")\n self.mpl_layoutBox = QtWidgets.QGridLayout(self.gridLayoutWidget)\n self.mpl_layoutBox.setContentsMargins(0, 0, 0, 0)\n self.mpl_layoutBox.setObjectName("mpl_layoutBox")\n self.pushButton = QtWidgets.QPushButton(self.centralwidget)\n self.pushButton.setGeometry(QtCore.QRect(280, 300, 113, 32))\n self.pushButton.setObjectName("pushButton")\n MainWindow.setCentralWidget(self.centralwidget)\n\n self.retranslateUi(MainWindow)\n QtCore.QMetaObject.connectSlotsByName(MainWindow)\n\n def retranslateUi(self, MainWindow):\n _translate = QtCore.QCoreApplication.translate\n MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))\n self.pushButton.setText(_translate("MainWindow", "PushButton"))\n\nif __name__ == "__main__":\n import sys\n\n app = QtWidgets.QApplication(sys.argv)\n MainWindow = QtWidgets.QMainWindow()\n ui = Ui_MainWindow()\n ui.setupUi(MainWindow)\n MainWindow.show()\n sys.exit(app.exec_())\n""")
我必须怎么做才能启用暗模式?
答案 0 :(得分:0)
好的,因此对我而言,尚不明确必须先将其编译为.app,然后再将NSRequiresAquaSystemAppearance
添加到顶级Info.plist
,但这已解决。