MacOS Mojave Dark Mode Support in PyQt 5.12.2

Ensuring your apps follow the desktop style
Heads up! You've already completed this tutorial.

MacOS Mojave, released in September of last year, introduced a user-toggleable "Dark Mode". This enables a system-wide dark color scheme, intended to make things easier on your eyes at night, or less distracting when working with content. The mode was supported by all built-in Mac apps on release, but 3rd party applications (including those developed with PyQt) were left looking a bit out of place.

The support for Dark Mode in Qt was targeted for 5.12 which landed in December 2018, with the first Python support in PyQt 5.12 released February 2019.

Early implementations had a few issues (see below) but as of PyQt 5.12.2 it's looking great. The pictures below show the same example app (just a random assortment of widgets) under Dark Mode and (default) Light Mode on MacOS Mojave.

python
pip3 install pyqt5==5.12.2

If you're on PyQt 5.12.2 or over Dark Mode is automatic. If your computer is in Dark Mode, your Qt apps should appear in the appropriate color scheme.

Example app on MacOS Mojave in Light Mode — PyQt 5.12.2 Example app on MacOS Mojave in Light Mode — PyQt 5.12.2

Example app on MacOS Mojave in Dark Mode — PyQt 5.12.2 Example app on MacOS Mojave in Dark Mode — PyQt 5.12.2

Issues on earlier versions

While PyQt 5.2.12 applications look great in Dark Mode, earlier versions have had a few issues. Below are a few screenshots of the same example app taken across earlier releases. If you're releasing your PyQt 5 apps to MacOS you might want to take a look at how it handles.

Downgrading to PyQt 5.12 produces the UI below — more or less fine, but with a missing color on the spin-wheel nubbin. It doesn't effect the functioning of the app, just looks a bit less nice.

python
pip3 install pyqt5==5.12

Example App in Dark Mode — PyQt 5.12, showing tiny style error Example App in Dark Mode — PyQt 5.12, showing tiny style error

Downgrading further to PyQt 5.10 produces this disaster. Strangely the wheel is now shaded properly, but the text is white-on-white.

python
    pip3 install pyqt5==5.10

Example App in Dark Mode — PyQt 5.10, it ain't pretty. Example App in Dark Mode — PyQt 5.10, it ain't pretty.

Weirdly, although PyQt 5.11 looks just as bad, 5.9 looks slightly better (as in potentially usable).

python
    pip3 install pyqt5==5.9

Example App in Dark Mode — PyQt 5.9, at least you can see some of the text Example App in Dark Mode — PyQt 5.9, at least you can see some of the text

The bottom line is: if you're targeting MacOS with your applications and using < PyQt5.12.2 then now would be a very good time to upgrade and ensure your app looks as great as it can under Mojave Dark Mode.

Create GUI Applications with Python & Qt6 by Martin Fitzpatrick — (PyQt6 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!

More info Get the book

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak

MacOS Mojave Dark Mode Support in PyQt 5.12.2 was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt.