albertosottile / darkdetect

Detect OS Dark Mode from Python
Other
171 stars 18 forks source link

[REQUEST] Watch for real-time theme changes #1

Closed midrare closed 4 years ago

midrare commented 4 years ago

If the theme is changed from light to dark while the app is running, the app will stay in light mode while the rest of the system changes to dark mode. If you watch for theme changes, you can adapt your Qt app to dark mode just like a native app.

albertosottile commented 4 years ago

Hi, thanks for suggesting this. darkdetect is based on a system API and does not cache the results, so every call to theme() will always return the current theme after each change. However, the UI app has to be written to adjust itself when such a change occurs. I do not see how I could change this package to facilitate this task.

For example, in your case, you should put a call in the UI thread loop of the Qt app that polls for darkdetect.theme() and redraws the interface according to the returned value. From what I can see, darkdetect already provides all the methods required to implement this feature.

On the other hand, if you have some implementation suggestions, I would be more than glad to hear them.