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_button import CTkButton
|
||||||
from .customtkinter_slider import CTkSlider
|
from .customtkinter_slider import CTkSlider
|
||||||
from .customtkinter_frame import CTkFrame
|
from .customtkinter_frame import CTkFrame
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import sys
|
import sys
|
||||||
|
from distutils.version import StrictVersion as Version
|
||||||
|
import darkdetect
|
||||||
|
|
||||||
if sys.platform == "darwin":
|
if Version(darkdetect.__version__) < Version("0.3.1"):
|
||||||
try:
|
sys.stderr.write("WARNING: You have to update the darkdetect library: pip3 install --upgrade darkdetect\n")
|
||||||
import darkdetect
|
if sys.platform != "darwin":
|
||||||
except ImportError as e:
|
exit()
|
||||||
sys.stderr.write(str(e) + "\nERROR: You have to install darkdetect: pip install darkdetect\n")
|
|
||||||
|
|
||||||
|
|
||||||
class SystemAppearanceModeListener(Thread):
|
class SystemAppearanceModeListener(Thread):
|
||||||
@ -35,7 +36,6 @@ class SystemAppearanceModeListener(Thread):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def detect_appearance_mode():
|
def detect_appearance_mode():
|
||||||
if sys.platform == "darwin":
|
|
||||||
try:
|
try:
|
||||||
if darkdetect.theme() == "Dark":
|
if darkdetect.theme() == "Dark":
|
||||||
return 1 # Dark
|
return 1 # Dark
|
||||||
@ -43,8 +43,6 @@ class SystemAppearanceModeListener(Thread):
|
|||||||
return 0 # Light
|
return 0 # Light
|
||||||
except NameError:
|
except NameError:
|
||||||
return 0 # Light
|
return 0 # Light
|
||||||
else:
|
|
||||||
return 0 # Light
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
while True:
|
||||||
@ -72,7 +70,6 @@ class SystemAppearanceModeListenerNoThread():
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def detect_appearance_mode():
|
def detect_appearance_mode():
|
||||||
if sys.platform == "darwin":
|
|
||||||
try:
|
try:
|
||||||
if darkdetect.theme() == "Dark":
|
if darkdetect.theme() == "Dark":
|
||||||
return 1 # Dark
|
return 1 # Dark
|
||||||
@ -80,8 +77,6 @@ class SystemAppearanceModeListenerNoThread():
|
|||||||
return 0 # Light
|
return 0 # Light
|
||||||
except NameError:
|
except NameError:
|
||||||
return 0 # Light
|
return 0 # Light
|
||||||
else:
|
|
||||||
return 0 # Light
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
detected_mode = self.detect_appearance_mode()
|
detected_mode = self.detect_appearance_mode()
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import tkinter
|
import tkinter
|
||||||
import customtkinter # <- import the CustomTkinter module
|
import customtkinter # <- import the CustomTkinter module
|
||||||
|
|
||||||
customtkinter.enable_macos_darkmode()
|
#customtkinter.enable_macos_darkmode()
|
||||||
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
#customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
||||||
|
|
||||||
root_tk = tkinter.Tk() # create the Tk window like you normally do
|
root_tk = tkinter.Tk() # create the Tk window like you normally do
|
||||||
root_tk.geometry("400x240")
|
root_tk.geometry("400x240")
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import tkinter
|
import tkinter
|
||||||
import customtkinter # <- import the CustomTkinter module
|
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.enable_macos_darkmode()
|
||||||
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
#customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
||||||
|
|
||||||
root_tk = tkinter.Tk() # create the Tk window like you normally do
|
root_tk = tkinter.Tk() # create the Tk window like you normally do
|
||||||
root_tk.geometry("400x240")
|
root_tk.geometry("400x240")
|
||||||
|
2
setup.py
2
setup.py
@ -10,7 +10,7 @@ def read(filename):
|
|||||||
|
|
||||||
|
|
||||||
setup(name="customtkinter",
|
setup(name="customtkinter",
|
||||||
version="1.0",
|
version="1.1",
|
||||||
author="Tom Schimansky",
|
author="Tom Schimansky",
|
||||||
license="Creative Commons Zero v1.0 Universal",
|
license="Creative Commons Zero v1.0 Universal",
|
||||||
url="https://github.com/TomSchimansky/CustomTkinter",
|
url="https://github.com/TomSchimansky/CustomTkinter",
|
||||||
|
Loading…
Reference in New Issue
Block a user