From d8ffaea25aa5d68c2e41b8f0346babad9e6d637b Mon Sep 17 00:00:00 2001 From: dez Date: Fri, 2 Feb 2024 15:01:18 +0100 Subject: [PATCH] WIP THEME DETECT --- src/gui_main.py | 5 +- src/theme_unix.py | 6 ++- src/theme_win.py | 120 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 src/theme_win.py diff --git a/src/gui_main.py b/src/gui_main.py index 4ea3fd8..b7a966f 100644 --- a/src/gui_main.py +++ b/src/gui_main.py @@ -5,10 +5,9 @@ from PIL import Image, ImageTk import download_main from gui_starfield import StarField -import darkdetect from json_main import save_package -def run_installer(download_folder_tmp): +def run_installer(download_folder_tmp, col_background, col_theme, col_isDark): global visible_widgets, tab_combobox # Declare tab_combobox as a global variable app = CTk() @@ -18,7 +17,7 @@ def run_installer(download_folder_tmp): app.minsize(width=800, height=600) app.maxsize(width=800, height=600) - app.isDark = darkdetect.isDark() + app.isDark = col_isDark if app.isDark: set_default_color_theme("dark-blue") diff --git a/src/theme_unix.py b/src/theme_unix.py index 0220b3b..722500f 100644 --- a/src/theme_unix.py +++ b/src/theme_unix.py @@ -32,5 +32,7 @@ def get_gtk_theme_colors(theme_name): print(f"Error: {e}") return None, None -background, foreground = get_gtk_theme_colors(theme_name) -print(f"Background color: #{background}, Foreground color: #{foreground}") \ No newline at end of file + +# # example use +# background, foreground = get_gtk_theme_colors(theme_name) +# print(f"Background color: #{background}, Foreground color: #{foreground}") \ No newline at end of file diff --git a/src/theme_win.py b/src/theme_win.py new file mode 100644 index 0000000..bd4cd87 --- /dev/null +++ b/src/theme_win.py @@ -0,0 +1,120 @@ +import ctypes + +def get_system_color(index): + return ctypes.windll.user32.GetSysColor(index) + +def color_value_to_rgb(color_value): + blue = color_value & 255 + green = (color_value >> 8) & 255 + red = (color_value >> 16) & 255 + return red, green, blue + +def main(): + # System color indexes + color_indexes = { + 1: "Scrollbar", + 2: "Background", + 3: "ActiveCaption", + 4: "InactiveCaption", + 5: "Menu", + 6: "Window", + 7: "WindowFrame", + 8: "MenuText", + 9: "WindowText", + 10: "CaptionText", + 11: "ActiveBorder", + 12: "InactiveBorder", + 13: "AppWorkspace", + 14: "Highlight", + 15: "HighlightText", + 16: "BtnFace", + 17: "BtnShadow", + 18: "GrayText", + 19: "BtnText", + 20: "InactiveCaptionText", + 21: "BtnHighlight", + 22: "3dDarkShadow", + 23: "3dLight", + 24: "InfoText", + 25: "InfoWindow", + 26: "HotLight", + 27: "GradientActiveCaption", + 28: "GradientInactiveCaption", + 29: "MenuHighlight", + 30: "MenuBar" + } + # Get and print system colors in RGB format + for index, name in color_indexes.items(): + color_value = get_system_color(index) + rgb_color = color_value_to_rgb(color_value) + print(f"{name}: RGB{rgb_color}") + +if __name__ == "__main__": + main() + + +# run 1 +# PS C:\msys64\home\Blazek_M\Launcher> python.exe .\src\theme_win.py +# Scrollbar: RGB(0, 0, 0) +# Background: RGB(209, 180, 153) +# ActiveCaption: RGB(219, 205, 191) +# InactiveCaption: RGB(240, 240, 240) +# Menu: RGB(255, 255, 255) +# Window: RGB(100, 100, 100) +# WindowFrame: RGB(0, 0, 0) +# MenuText: RGB(0, 0, 0) +# WindowText: RGB(0, 0, 0) +# CaptionText: RGB(180, 180, 180) +# ActiveBorder: RGB(252, 247, 244) +# InactiveBorder: RGB(171, 171, 171) +# AppWorkspace: RGB(215, 120, 0) +# Highlight: RGB(255, 255, 255) +# HighlightText: RGB(240, 240, 240) +# BtnFace: RGB(160, 160, 160) +# BtnShadow: RGB(109, 109, 109) +# GrayText: RGB(0, 0, 0) +# BtnText: RGB(0, 0, 0) +# InactiveCaptionText: RGB(255, 255, 255) +# BtnHighlight: RGB(105, 105, 105) +# 3dDarkShadow: RGB(227, 227, 227) +# 3dLight: RGB(0, 0, 0) +# InfoText: RGB(225, 255, 255) +# InfoWindow: RGB(0, 0, 0) +# HotLight: RGB(204, 102, 0) +# GradientActiveCaption: RGB(234, 209, 185) +# GradientInactiveCaption: RGB(242, 228, 215) +# MenuHighlight: RGB(255, 153, 51) +# MenuBar: RGB(240, 240, 240) + +# run 2 +# PS C:\msys64\home\Blazek_M\Launcher> python.exe .\src\theme_win.py +# Scrollbar: RGB(0, 0, 0) +# Background: RGB(209, 180, 153) +# ActiveCaption: RGB(219, 205, 191) +# InactiveCaption: RGB(240, 240, 240) +# Menu: RGB(255, 255, 255) +# Window: RGB(100, 100, 100) +# WindowFrame: RGB(0, 0, 0) +# MenuText: RGB(0, 0, 0) +# WindowText: RGB(0, 0, 0) +# CaptionText: RGB(180, 180, 180) +# ActiveBorder: RGB(252, 247, 244) +# InactiveBorder: RGB(171, 171, 171) +# AppWorkspace: RGB(215, 120, 0) +# Highlight: RGB(255, 255, 255) +# HighlightText: RGB(240, 240, 240) +# BtnFace: RGB(160, 160, 160) +# BtnShadow: RGB(109, 109, 109) +# GrayText: RGB(0, 0, 0) +# BtnText: RGB(0, 0, 0) +# InactiveCaptionText: RGB(255, 255, 255) +# BtnHighlight: RGB(105, 105, 105) +# 3dDarkShadow: RGB(227, 227, 227) +# 3dLight: RGB(0, 0, 0) +# InfoText: RGB(225, 255, 255) +# InfoWindow: RGB(0, 0, 0) +# HotLight: RGB(204, 102, 0) +# GradientActiveCaption: RGB(234, 209, 185) +# GradientInactiveCaption: RGB(242, 228, 215) +# MenuHighlight: RGB(255, 153, 51) +# MenuBar: RGB(240, 240, 240) \ No newline at end of file