Files
thechart/scripts/verify_headers.py

81 lines
2.4 KiB
Python

#!/usr/bin/env python3
"""Verify header visibility across all themes."""
import sys
import tkinter as tk
from pathlib import Path
from init import logger
from theme_manager import ThemeManager
# Add src directory to Python path
src_path = Path(__file__).parent / "src"
sys.path.insert(0, str(src_path))
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)
# Determine status
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()