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":
bg, fg = "#0f0f10", "#f1f1f1"
status_fg = "#f5f5f5"
highlight_fg = "#f2c744"
else:
bg, fg = "#ededf2", "#202020"
status_fg = "#1c1c1c"
highlight_fg = "#c56217"
self.root.configure(bg=bg) # type: ignore[attr-defined]
s = self.style
@ -61,6 +63,10 @@ class ThemeMixin:
if callable(status_refresher) and hasattr(self, "status"):
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:
"""Best-effort detection of the OS theme preference."""
try:

View File

@ -98,26 +98,24 @@ class UIBuilderMixin:
info_frame = ttk.Frame(self.root)
info_frame.pack(fill=tk.X, padx=12, pady=(0, 12))
self.filename_label = ttk.Label(
info_frame,
text="",
foreground="#f2c744",
font=("Segoe UI", 10, "bold"),
anchor="center",
justify="center",
)
self.filename_label.pack(anchor="center")
self.filename_label = ttk.Label(
info_frame,
text="",
font=("Segoe UI", 10, "bold"),
anchor="center",
justify="center",
)
self.filename_label.pack(anchor="center")
self._attach_copy_menu(self.filename_label)
self.ratio_label = ttk.Label(
info_frame,
text="Markierungen (mit Ausschlüssen): —",
foreground="#f2c744",
font=("Segoe UI", 10, "bold"),
anchor="center",
justify="center",
)
self.ratio_label.pack(anchor="center", pady=(4, 0))
font=("Segoe UI", 10, "bold"),
anchor="center",
justify="center",
)
self.ratio_label.pack(anchor="center", pady=(4, 0))
self._attach_copy_menu(self.ratio_label)
self.root.bind("<Escape>", self.disable_pick_mode)
@ -495,9 +493,16 @@ class UIBuilderMixin:
activeforeground=palette["fg"],
)
def _refresh_status_palette(self, fg: str) -> None:
self.status.configure(foreground=fg)
self._status_palette["fg"] = fg
def _refresh_status_palette(self, fg: str) -> None:
self.status.configure(foreground=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):
self._copy_target = None