Tint accent labels based on theme

This commit is contained in:
lm 2025-10-17 15:53:51 +02:00
parent 1024d84bbc
commit e3013bd305
2 changed files with 29 additions and 18 deletions

View File

@ -36,9 +36,11 @@ class ThemeMixin:
if self.theme == "dark": if self.theme == "dark":
bg, fg = "#0f0f10", "#f1f1f1" bg, fg = "#0f0f10", "#f1f1f1"
status_fg = "#f5f5f5" status_fg = "#f5f5f5"
highlight_fg = "#f2c744"
else: else:
bg, fg = "#ededf2", "#202020" bg, fg = "#ededf2", "#202020"
status_fg = "#1c1c1c" status_fg = "#1c1c1c"
highlight_fg = "#c56217"
self.root.configure(bg=bg) # type: ignore[attr-defined] self.root.configure(bg=bg) # type: ignore[attr-defined]
s = self.style s = self.style
@ -61,6 +63,10 @@ class ThemeMixin:
if callable(status_refresher) and hasattr(self, "status"): if callable(status_refresher) and hasattr(self, "status"):
status_refresher(status_fg) status_refresher(status_fg)
accent_refresher = getattr(self, "_refresh_accent_labels", None)
if callable(accent_refresher) and hasattr(self, "filename_label"):
accent_refresher(highlight_fg)
def detect_system_theme(self) -> str: def detect_system_theme(self) -> str:
"""Best-effort detection of the OS theme preference.""" """Best-effort detection of the OS theme preference."""
try: try:

View File

@ -101,7 +101,6 @@ class UIBuilderMixin:
self.filename_label = ttk.Label( self.filename_label = ttk.Label(
info_frame, info_frame,
text="", text="",
foreground="#f2c744",
font=("Segoe UI", 10, "bold"), font=("Segoe UI", 10, "bold"),
anchor="center", anchor="center",
justify="center", justify="center",
@ -112,7 +111,6 @@ class UIBuilderMixin:
self.ratio_label = ttk.Label( self.ratio_label = ttk.Label(
info_frame, info_frame,
text="Markierungen (mit Ausschlüssen): —", text="Markierungen (mit Ausschlüssen): —",
foreground="#f2c744",
font=("Segoe UI", 10, "bold"), font=("Segoe UI", 10, "bold"),
anchor="center", anchor="center",
justify="center", justify="center",
@ -499,6 +497,13 @@ class UIBuilderMixin:
self.status.configure(foreground=fg) self.status.configure(foreground=fg)
self._status_palette["fg"] = fg self._status_palette["fg"] = fg
def _refresh_accent_labels(self, colour: str) -> None:
try:
self.filename_label.configure(foreground=colour)
self.ratio_label.configure(foreground=colour)
except Exception:
pass
def _init_copy_menu(self): def _init_copy_menu(self):
self._copy_target = None self._copy_target = None
self.copy_menu = tk.Menu(self.root, tearoff=0) self.copy_menu = tk.Menu(self.root, tearoff=0)