mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
added darkdetect Windows and Linux support
This commit is contained in:
parent
96462ea600
commit
54ede3a548
@ -1,3 +1,5 @@
|
||||
__version__ = "1.1"
|
||||
|
||||
from .customtkinter_button import CTkButton
|
||||
from .customtkinter_slider import CTkSlider
|
||||
from .customtkinter_frame import CTkFrame
|
||||
|
@ -1,12 +1,13 @@
|
||||
from threading import Thread
|
||||
from time import sleep
|
||||
import sys
|
||||
from distutils.version import StrictVersion as Version
|
||||
import darkdetect
|
||||
|
||||
if sys.platform == "darwin":
|
||||
try:
|
||||
import darkdetect
|
||||
except ImportError as e:
|
||||
sys.stderr.write(str(e) + "\nERROR: You have to install darkdetect: pip install darkdetect\n")
|
||||
if Version(darkdetect.__version__) < Version("0.3.1"):
|
||||
sys.stderr.write("WARNING: You have to update the darkdetect library: pip3 install --upgrade darkdetect\n")
|
||||
if sys.platform != "darwin":
|
||||
exit()
|
||||
|
||||
|
||||
class SystemAppearanceModeListener(Thread):
|
||||
@ -35,7 +36,6 @@ class SystemAppearanceModeListener(Thread):
|
||||
|
||||
@staticmethod
|
||||
def detect_appearance_mode():
|
||||
if sys.platform == "darwin":
|
||||
try:
|
||||
if darkdetect.theme() == "Dark":
|
||||
return 1 # Dark
|
||||
@ -43,8 +43,6 @@ class SystemAppearanceModeListener(Thread):
|
||||
return 0 # Light
|
||||
except NameError:
|
||||
return 0 # Light
|
||||
else:
|
||||
return 0 # Light
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
@ -72,7 +70,6 @@ class SystemAppearanceModeListenerNoThread():
|
||||
|
||||
@staticmethod
|
||||
def detect_appearance_mode():
|
||||
if sys.platform == "darwin":
|
||||
try:
|
||||
if darkdetect.theme() == "Dark":
|
||||
return 1 # Dark
|
||||
@ -80,8 +77,6 @@ class SystemAppearanceModeListenerNoThread():
|
||||
return 0 # Light
|
||||
except NameError:
|
||||
return 0 # Light
|
||||
else:
|
||||
return 0 # Light
|
||||
|
||||
def update(self):
|
||||
detected_mode = self.detect_appearance_mode()
|
||||
|
@ -1,8 +1,8 @@
|
||||
import tkinter
|
||||
import customtkinter # <- import the CustomTkinter module
|
||||
|
||||
customtkinter.enable_macos_darkmode()
|
||||
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
||||
#customtkinter.enable_macos_darkmode()
|
||||
#customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
||||
|
||||
root_tk = tkinter.Tk() # create the Tk window like you normally do
|
||||
root_tk.geometry("400x240")
|
||||
|
@ -1,9 +1,9 @@
|
||||
import tkinter
|
||||
import customtkinter # <- import the CustomTkinter module
|
||||
from PIL import Image, ImageTk # <- import PIL for the images
|
||||
#from PIL import Image, ImageTk # <- import PIL for the images
|
||||
|
||||
customtkinter.enable_macos_darkmode()
|
||||
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
||||
#customtkinter.enable_macos_darkmode()
|
||||
#customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
||||
|
||||
root_tk = tkinter.Tk() # create the Tk window like you normally do
|
||||
root_tk.geometry("400x240")
|
||||
|
Loading…
Reference in New Issue
Block a user