Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you enable macOS Dark Mode in PyQt5 (5.13)

Tags:

python

qt5

pyqt5

I am making my first GUI application with PyQt5 but it does not currently work with dark mode.

How do you enable dark mode in PyQt5?

I user PyQt5 v5.13.0 and freeze the app with PyInstaller on Mac, Linux and Windows.

If you need more information or some of the code, please tell me.

like image 710
JSogaard Avatar asked Aug 26 '19 14:08

JSogaard


1 Answers

Workaround for macOS X.

  1. Install PyQt5 5.12.2

    pip3 install pyqt5==5.12.2
    
  2. Compile your app

  3. Add this into info.plist:

    <key>NSRequiresAquaSystemAppearance</key>
    <string>False</string>
    

There is no much difference between 5.12.2 and 5.13.0 but later doesn't support native dark mode on macOS.

On other platforms write separate style sheets and add trigger in settings or read system variable.

like image 65
Rocket Nikita Avatar answered Sep 30 '22 15:09

Rocket Nikita