#!/usr/bin/env python3 """Test script to check table header visibility in Arc theme.""" # ruff: noqa: E402 import sys import tkinter as tk from pathlib import Path from tkinter import ttk # 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")) # Add src directory to Python path src_path = Path(__file__).parent / "src" sys.path.insert(0, str(src_path)) def test_arc_theme_headers(): """Test Arc theme table header visibility.""" print("Testing Arc theme table header colors...") # Create a test tkinter window root = tk.Tk() root.title("Arc Theme Header Test") root.geometry("600x400") # Initialize theme manager theme_manager = ThemeManager(root, logger) # Apply Arc theme success = theme_manager.apply_theme("arc") print(f"Arc theme applied: {success}") # Get theme colors colors = theme_manager.get_theme_colors() print(f"Theme colors: {colors}") # Create a test treeview with headers frame = ttk.Frame(root) frame.pack(fill="both", expand=True, padx=20, pady=20) # Create treeview with Modern.Treeview style tree = ttk.Treeview( frame, columns=("col1", "col2", "col3"), show="headings", style="Modern.Treeview", ) # Configure headers tree.heading("col1", text="Date") tree.heading("col2", text="Medicine") tree.heading("col3", text="Notes") # Add some sample data tree.insert("", "end", values=("2025-08-05", "Aspirin", "Sample note")) tree.insert("", "end", values=("2025-08-06", "Vitamin D", "Another note")) tree.pack(fill="both", expand=True) # Get the actual style configuration style = theme_manager.style if style: try: # Check the Modern.Treeview.Heading configuration heading_config = style.configure("Modern.Treeview.Heading") print(f"Header style config: {heading_config}") # Check if we can get specific colors header_bg = style.lookup("Modern.Treeview.Heading", "background") header_fg = style.lookup("Modern.Treeview.Heading", "foreground") print(f"Header background: {header_bg}") print(f"Header foreground: {header_fg}") # Check the base Treeview.Heading style from Arc theme base_heading_config = style.configure("Treeview.Heading") print(f"Base header style: {base_heading_config}") base_header_bg = style.lookup("Treeview.Heading", "background") base_header_fg = style.lookup("Treeview.Heading", "foreground") print(f"Base header background: {base_header_bg}") print(f"Base header foreground: {base_header_fg}") except Exception as e: print(f"Error getting style info: {e}") # Add a label with color info info_text = ( f"Arc Theme Colors - BG: {colors.get('bg', 'N/A')}, " f"FG: {colors.get('fg', 'N/A')}, " f"Select BG: {colors.get('select_bg', 'N/A')}, " f"Select FG: {colors.get('select_fg', 'N/A')}" ) info_label = ttk.Label(root, text=info_text) info_label.pack(pady=10) print("Window created. Check if table headers are visible.") print("Close the window to see the color analysis.") root.mainloop() if __name__ == "__main__": test_arc_theme_headers()