Skip to content

Commit 99bf758

Browse files
removed dark detect, improved button colouring
1 parent e82a5de commit 99bf758

5 files changed

Lines changed: 38 additions & 16 deletions

File tree

Python_Engine/Python/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ dependencies = [
1616
"pytest-cov>=6.0.0",
1717
"pytest-order",
1818
"virtualenv",
19-
"darkdetect"
2019
]
2120

2221
[urls]

Python_Engine/Python/src/python_toolkit/bhom/bhom_dark_theme.tcl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace eval ttk::theme::bhom_dark {
3232
-disabled-fg "#666666"
3333
-inputbg "#2d2d2d"
3434
-inputfg "#ffffff"
35-
-hover-bg "#2a2d2e"
35+
-hover-bg "#424242"
3636
-active-bg "#383838"
3737
-text-secondary "#999999"
3838
}
@@ -159,20 +159,20 @@ namespace eval ttk::theme::bhom_dark {
159159

160160
ttk::style map TButton \
161161
-background [list \
162-
active $colors(-primary-hover) \
162+
active $colors(-hover-bg) \
163163
pressed $colors(-active-bg) \
164164
disabled $colors(-disabled-bg)] \
165165
-foreground [list \
166166
active $colors(-fg) \
167167
disabled $colors(-disabled-fg)] \
168168
-bordercolor [list \
169-
active $colors(-primary-hover) \
169+
active $colors(-hover-bg) \
170170
disabled $colors(-border)] \
171171
-lightcolor [list \
172-
active $colors(-primary-hover) \
172+
active $colors(-hover-bg) \
173173
pressed $colors(-active-bg)] \
174174
-darkcolor [list \
175-
active $colors(-primary-hover) \
175+
active $colors(-hover-bg) \
176176
pressed $colors(-active-bg)] \
177177
-relief [list \
178178
pressed sunken]

Python_Engine/Python/src/python_toolkit/bhom/bhom_light_theme.tcl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace eval ttk::theme::bhom_light {
3232
-disabled-fg "#999999"
3333
-inputbg "#ffffff"
3434
-inputfg "#1a1a1a"
35-
-hover-bg "#f5f5f5"
35+
-hover-bg "#e0e0e0"
3636
-active-bg "#ececec"
3737
-text-secondary "#666666"
3838
}
@@ -159,20 +159,20 @@ namespace eval ttk::theme::bhom_light {
159159

160160
ttk::style map TButton \
161161
-background [list \
162-
active $colors(-primary-hover) \
162+
active $colors(-hover-bg) \
163163
pressed $colors(-active-bg) \
164164
disabled $colors(-disabled-bg)] \
165165
-foreground [list \
166166
active $colors(-fg) \
167167
disabled $colors(-disabled-fg)] \
168168
-bordercolor [list \
169-
active $colors(-primary-hover) \
169+
active $colors(-hover-bg) \
170170
disabled $colors(-border)] \
171171
-lightcolor [list \
172-
active $colors(-primary-hover) \
172+
active $colors(-hover-bg) \
173173
pressed $colors(-active-bg)] \
174174
-darkcolor [list \
175-
active $colors(-primary-hover) \
175+
active $colors(-hover-bg) \
176176
pressed $colors(-active-bg)] \
177177
-relief [list \
178178
pressed sunken]
@@ -195,11 +195,14 @@ namespace eval ttk::theme::bhom_light {
195195
pressed $colors(-primary-hover) \
196196
disabled $colors(-disabled-bg)] \
197197
-lightcolor [list \
198-
active $colors(-primary-light) \
198+
active $colors(-primary-hover) \
199199
pressed $colors(-primary-hover)] \
200200
-darkcolor [list \
201201
active $colors(-primary-hover) \
202202
pressed $colors(-primary-hover)] \
203+
-foreground [list \
204+
active "#ffffff" \
205+
disabled $colors(-disabled-fg)] \
203206
-relief [list \
204207
pressed sunken]
205208

Python_Engine/Python/src/python_toolkit/bhom_tkinter/bhom_base_window.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from python_toolkit.bhom_tkinter.widgets.label import Label
66
from pathlib import Path
77
from typing import Optional, Callable, Literal, List
8-
import darkdetect
98
import platform
109
import ctypes
1110
import os
@@ -236,8 +235,9 @@ def _determine_theme(
236235
return theme_path_dark, dark_logo_path, dark_icon_path, "dark"
237236

238237
#case == auto - detect system theme preference
239-
if darkdetect.isDark():
238+
if self._is_windows_dark_mode():
240239
return theme_path_dark, dark_logo_path, dark_icon_path, "dark"
240+
241241
else:
242242
return theme_path_light, logo_path, icon_path, "light"
243243

@@ -336,6 +336,27 @@ def _load_theme(self, _theme_path: Path) -> str:
336336
except Exception:
337337
return "default"
338338

339+
def _is_windows_dark_mode(self) -> bool:
340+
341+
try:
342+
343+
import winreg
344+
key = winreg.OpenKey(
345+
winreg.HKEY_CURRENT_USER,
346+
r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"
347+
)
348+
value, _ = winreg.QueryValueEx(key, "AppsUseLightTheme")
349+
350+
return value == 0 # 0 means dark mode, 1 means light mode
351+
352+
except FileNotFoundError:
353+
# Key may not exist on older Windows versions
354+
return False
355+
356+
except ImportError:
357+
# winreg is only available on Windows
358+
return False
359+
339360
def _ensure_typography_styles(self, style: ttk.Style) -> None:
340361
"""Ensure key typography styles exist and remain visually distinct."""
341362
defaults = {
@@ -660,7 +681,7 @@ def _on_close_window(self, callback: Optional[Callable]) -> None:
660681

661682
test = BHoMBaseWindow(
662683
title="Test Window",
663-
theme_mode="dark",
684+
theme_mode="light",
664685
)
665686

666687
test.widgets.append(Label(test.content_frame, text="Hello, World!"))

Python_Engine/Python/src/python_toolkit/bhom_tkinter/widgets/button.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,3 @@ def demo_action():
8585
widget.build()
8686

8787
root.mainloop()
88-

0 commit comments

Comments
 (0)