From 87df764002d1f75791b023a84565a0d9e3bff0be Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sat, 6 Mar 2021 17:33:38 +0100 Subject: [PATCH] darkdetct --- customtkinter/appearance_mode_tracker.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/customtkinter/appearance_mode_tracker.py b/customtkinter/appearance_mode_tracker.py index 8dc2a69..d76d6c9 100644 --- a/customtkinter/appearance_mode_tracker.py +++ b/customtkinter/appearance_mode_tracker.py @@ -6,7 +6,7 @@ if sys.platform == "darwin": try: import darkdetect except ImportError as e: - sys.stderr.write(e + "\nYou have to install darkdetect: pip install darkdetect") + sys.stderr.write(str(e) + "\nERROR: You have to install darkdetect: pip install darkdetect\n") class SystemAppearanceModeListener(Thread): @@ -36,9 +36,12 @@ class SystemAppearanceModeListener(Thread): @staticmethod def detect_appearance_mode(): if sys.platform == "darwin": - if darkdetect.theme() == "Dark": - return 1 # Dark - else: + try: + if darkdetect.theme() == "Dark": + return 1 # Dark + else: + return 0 # Light + except NameError: return 0 # Light else: return 0 # Light @@ -70,9 +73,12 @@ class SystemAppearanceModeListenerNoThread(): @staticmethod def detect_appearance_mode(): if sys.platform == "darwin": - if darkdetect.theme() == "Dark": - return 1 # Dark - else: + try: + if darkdetect.theme() == "Dark": + return 1 # Dark + else: + return 0 # Light + except NameError: return 0 # Light else: return 0 # Light