#!/usr/bin/env python3 """Verify header visibility across all themes.""" # ruff: noqa: E402 import sys import tkinter as tk from pathlib import Path # Ensure the 'src' directory is on sys.path so 'thechart' package is importable SRC_DIR = Path(__file__).resolve().parent.parent / "src" if str(SRC_DIR) not in sys.path: sys.path.insert(0, str(SRC_DIR)) from thechart.core.constants import LOG_LEVEL from thechart.core.logger import init_logger from thechart.ui import ThemeManager logger = init_logger(__name__, testing_mode=(LOG_LEVEL == "DEBUG")) def verify_all_themes(): """Verify header visibility for all themes.""" print("=== HEADER VISIBILITY VERIFICATION ===\n") root = tk.Tk() root.withdraw() # Hide window theme_manager = ThemeManager(root, logger) available_themes = theme_manager.get_available_themes() print(f"Testing {len(available_themes)} themes...") print("-" * 50) for theme in available_themes: print(f"\nšŸŽØ {theme.upper()} THEME") # Apply theme success = theme_manager.apply_theme(theme) if not success: print("āŒ Failed to apply theme") continue # Get colors colors = theme_manager.get_theme_colors() header_colors = theme_manager._get_contrasting_colors(colors) # Calculate contrast ratio def get_luminance(color_str): """Calculate relative luminance.""" if not color_str or not color_str.startswith("#"): return 0.5 try: rgb = tuple(int(color_str[i : i + 2], 16) for i in (1, 3, 5)) return (0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]) / 255 except (ValueError, IndexError): return 0.5 bg_lum = get_luminance(header_colors["header_bg"]) fg_lum = get_luminance(header_colors["header_fg"]) lighter = max(bg_lum, fg_lum) darker = min(bg_lum, fg_lum) contrast_ratio = (lighter + 0.05) / (darker + 0.05) if contrast_ratio >= 4.5: status = "āœ… EXCELLENT" elif contrast_ratio >= 3.0: status = "āœ… GOOD" elif contrast_ratio >= 2.0: status = "āš ļø FAIR" else: status = "āŒ POOR" print(f" Header: {header_colors['header_bg']} / {header_colors['header_fg']}") print(f" Contrast: {contrast_ratio:.2f}:1 {status}") print("\n" + "=" * 50) print("āœ… Header visibility verification complete!") print("All themes should now have readable table headers.") root.destroy() if __name__ == "__main__": verify_all_themes()