darkdetect


Namedarkdetect JSON
Version 0.7.1 PyPI version JSON
download
home_pagehttp://github.com/albertosottile/darkdetect
SummaryDetect OS Dark Mode from Python
upload_time2022-07-18 21:10:27
maintainer
docs_urlNone
authorAlberto Sottile
requires_python
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Darkdetect

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

- [macOS 10.14+](https://support.apple.com/en-us/HT208976)
- [Windows 10 1607+](https://blogs.windows.com/windowsexperience/2016/08/08/windows-10-tip-personalize-your-pc-by-enabling-the-dark-theme/)
- Linux with [a dark GTK theme](https://www.gnome-look.org/browse/cat/135/ord/rating/?tag=dark).

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.

``` python
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()
```

*On macOS it simply raises a NotImplementedError. PRs in this direction are more than welcome.*

## 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](https://medium.com/underdog-io-engineering/vendoring-python-dependencies-with-pip-b9eb6078b9c0).

## 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](https://stackoverflow.com/questions/25207077/how-to-detect-if-os-x-is-in-dark-mode) on the detection method used on macOS.
- [Details](https://askubuntu.com/questions/1261366/detecting-dark-mode#comment2132694_1261366) on the experimental detection method used on Linux.

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/albertosottile/darkdetect",
    "name": "darkdetect",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Alberto Sottile",
    "author_email": "asottile@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/48/2e/346667de53b48417e6237efd9d076d6530c413666fcbc381adbfeff21ce7/darkdetect-0.7.1.tar.gz",
    "platform": null,
    "description": "# Darkdetect\n\nThis package allows to detect if the user is using Dark Mode on:\n\n- [macOS 10.14+](https://support.apple.com/en-us/HT208976)\n- [Windows 10 1607+](https://blogs.windows.com/windowsexperience/2016/08/08/windows-10-tip-personalize-your-pc-by-enabling-the-dark-theme/)\n- Linux with [a dark GTK theme](https://www.gnome-look.org/browse/cat/135/ord/rating/?tag=dark).\n\nThe 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.\n\n\n## Usage\n\n```\nimport darkdetect\n\n>>> darkdetect.theme()\n'Dark'\n\n>>> darkdetect.isDark()\nTrue\n\n>>> darkdetect.isLight()\nFalse\n```\nIt's that easy.\n\nYou 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.\n\n``` python\nimport threading\nimport darkdetect\n\n# def listener(callback: typing.Callable[[str], None]) -> None: ...\n\nt = threading.Thread(target=darkdetect.listener, args=(print,))\nt.daemon = True\nt.start()\n```\n\n*On macOS it simply raises a NotImplementedError. PRs in this direction are more than welcome.*\n\n## Install\n\nThe preferred channel is PyPI:\n```\npip install darkdetect\n```\n\nAlternatively, you are free to vendor directly a copy of Darkdetect in your app. Further information on vendoring can be found [here](https://medium.com/underdog-io-engineering/vendoring-python-dependencies-with-pip-b9eb6078b9c0).\n\n## Notes\n\n- This software is licensed under the terms of the 3-clause BSD License.\n- 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.\n- On macOS, detection of the dark menu bar and dock option (available from macOS 10.10) is not supported.\n- [Details](https://stackoverflow.com/questions/25207077/how-to-detect-if-os-x-is-in-dark-mode) on the detection method used on macOS.\n- [Details](https://askubuntu.com/questions/1261366/detecting-dark-mode#comment2132694_1261366) on the experimental detection method used on Linux.\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Detect OS Dark Mode from Python",
    "version": "0.7.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "9ecef5c145fa041c2db78af6d004c207",
                "sha256": "3efe69f8ecd5f1b7f4fbb0d1d93f656b0e493c45cc49222380ffe2a529cbc866"
            },
            "downloads": -1,
            "filename": "darkdetect-0.7.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9ecef5c145fa041c2db78af6d004c207",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 8199,
            "upload_time": "2022-07-18T21:10:26",
            "upload_time_iso_8601": "2022-07-18T21:10:26.178120Z",
            "url": "https://files.pythonhosted.org/packages/63/bd/b31abc8fcaab163e0b9501020309dd9094b47d609035a23e6ec0a0a8ba10/darkdetect-0.7.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "d21ffe3b46c41ae9660f064cbd1b9495",
                "sha256": "47be3cf5134432ddb616bbffc927237718407914993c82809983e7ccebf49013"
            },
            "downloads": -1,
            "filename": "darkdetect-0.7.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d21ffe3b46c41ae9660f064cbd1b9495",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6976,
            "upload_time": "2022-07-18T21:10:27",
            "upload_time_iso_8601": "2022-07-18T21:10:27.640754Z",
            "url": "https://files.pythonhosted.org/packages/48/2e/346667de53b48417e6237efd9d076d6530c413666fcbc381adbfeff21ce7/darkdetect-0.7.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-07-18 21:10:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "albertosottile",
    "github_project": "darkdetect",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "darkdetect"
}
        
Elapsed time: 0.01621s