Skip to main content

Darkdetect

This package allows to detect if the user is using Dark Mode on:

The main application of this package is to detect the Dark mode from your GUI Python application (Tkinter/wx/pyqt/qt for python (pyside)/...) and apply the needed adjustments to your interface. Darkdetect is particularly useful if your GUI library does not provide a public API for this detection (I am looking at you, Qt). In addition, this package does not depend on other modules or packages that are not already included in standard Python distributions.

Usage

import darkdetect

>>> darkdetect.theme()
'Dark'

>>> darkdetect.isDark()
True

>>> darkdetect.isLight()
False

It's that easy.

You can create a dark mode switch listener daemon thread with darkdetect.listener and pass a callback function. The function will be called with string "Dark" or "Light" when the OS switches the dark mode setting.

import threading
import darkdetect

# def listener(callback: typing.Callable[[str], None]) -> None: ...

t = threading.Thread(target=darkdetect.listener, args=(print,))
t.daemon = True
t.start()

Install

The preferred channel is PyPI:

pip install darkdetect

Alternatively, you are free to vendor directly a copy of Darkdetect in your app. Further information on vendoring can be found here.

Optional Installs

To enable the macOS listener, additional components are required, these can be installed via:

pip install darkdetect[macos-listener]

Notes

  • This software is licensed under the terms of the 3-clause BSD License.
  • This package can be installed on any operative system, but it will always return None unless executed on a OS that supports Dark Mode, including older versions of macOS and Windows.
  • On macOS, detection of the dark menu bar and dock option (available from macOS 10.10) is not supported.
  • Details on the detection method used on macOS.
  • Details on the experimental detection method used on Linux.

Metadata

Release files for darkdetect 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for darkdetect 0.8.0
File Size Uploaded Provenance
darkdetect-0.8.0.tar.gz 7.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for darkdetect 0.8.0
File Interpreter ABI Platform
darkdetect-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / darkdetect-0.8.0.tar.gz

Download URL darkdetect-0.8.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b5428e1170263eb5dea44c25dc3895edd75e6f52300986353cd63533fe7df8b1
BLAKE2b-256 checksum
How to use checksums
45777575be73bf12dee231d0c6e60ce7fb7a7be4fcd58823374fc59a6e48262e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release files / darkdetect-0.8.0-py3-none-any.whl

Download URL darkdetect-0.8.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7509ccf517eaad92b31c214f593dbcf138ea8a43b2935406bbd565e15527a85
BLAKE2b-256 checksum
How to use checksums
f2f2728f041460f1b9739b85ee23b45fa5a505962ea11fd85bdbe2a02b021373
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Security for darkdetect 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page