问题
I would like to know to enable the native MacOS Mojave Dark Theme (and if could be multiplatform win/linux, the better) which is supposed to be available from QT 5.12 (which I guess, it should be available in PySide2).
By default, the apps are still the same way, I don't know what to do to enable it.
Thanks!!
P.S.: using python 2.7.10 (and the solution of pyinstaler works!!, but not running python directly)
回答1:
It's not clear how are you running your application. As a module
python -m application
or
python application.py
For me with python 3.7.3 installed with homebrew just works.
But if you are using pyinstaller in the spec file in the section app = BUNDLE add this
info_plist={
'NSRequiresAquaSystemAppearance': 'No'
},
App bundles I create with this option work in Dark Mode or Light Mode the application changes the interface to use the appropriate one.
回答2:
For MacOS applications to support dark mode, they either need to be built against the macOS 10.14 or later SDK, or to include the 'NSRequiresAquaSystemAppearance': 'No'
property mentioned by @efrain.
See https://developer.apple.com/documentation/appkit/nsappearancecustomization/choosing_a_specific_appearance_for_your_macos_app for further details.
To get dark mode when running your app directly with Python, you'll need to ensure your Python binary was built against macOS 10.4 or later. The easiest way to do this is probably to use pyenv to manage your Python installation.
来源:https://stackoverflow.com/questions/54106717/enable-native-macos-mojave-dark-theme-pyside2-python-apps-on-qt-5-12