92 lines
2.7 KiB
Python
92 lines
2.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Test the improved header visibility fix."""
|
|
|
|
import sys
|
|
import tkinter as tk
|
|
from pathlib import Path
|
|
from tkinter import ttk
|
|
|
|
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 test_improved_headers():
|
|
"""Test the improved header visibility."""
|
|
print("Testing improved header visibility...")
|
|
|
|
root = tk.Tk()
|
|
root.title("Improved Header Test")
|
|
root.geometry("800x500")
|
|
|
|
# Initialize theme manager
|
|
theme_manager = ThemeManager(root, logger)
|
|
|
|
# Test problematic themes
|
|
test_themes = ["arc", "plastik", "elegance", "equilux"]
|
|
|
|
main_frame = ttk.Frame(root)
|
|
main_frame.pack(fill="both", expand=True, padx=20, pady=20)
|
|
|
|
# Create notebook for different themes
|
|
notebook = ttk.Notebook(main_frame)
|
|
notebook.pack(fill="both", expand=True)
|
|
|
|
for theme in test_themes:
|
|
if theme not in theme_manager.get_available_themes():
|
|
continue
|
|
|
|
print(f"Testing theme: {theme}")
|
|
theme_manager.apply_theme(theme)
|
|
|
|
# Create a tab for this theme
|
|
tab_frame = ttk.Frame(notebook)
|
|
notebook.add(tab_frame, text=theme.title())
|
|
|
|
# Create treeview for this theme
|
|
tree = ttk.Treeview(
|
|
tab_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")
|
|
|
|
# Configure columns
|
|
tree.column("col1", width=120, anchor="center")
|
|
tree.column("col2", width=150, anchor="center")
|
|
tree.column("col3", width=300, anchor="w")
|
|
|
|
# Add sample data
|
|
tree.insert("", "end", values=("2025-08-05", "Aspirin", "Morning dose"))
|
|
tree.insert("", "end", values=("2025-08-06", "Vitamin D", "With breakfast"))
|
|
tree.insert("", "end", values=("2025-08-07", "Fish Oil", "Evening dose"))
|
|
|
|
tree.pack(fill="both", expand=True, padx=10, pady=10)
|
|
|
|
# Get colors for this theme
|
|
colors = theme_manager.get_theme_colors()
|
|
header_colors = theme_manager._get_contrasting_colors(colors)
|
|
|
|
# Add info label
|
|
info_text = (
|
|
f"Header: {header_colors['header_bg']} / {header_colors['header_fg']} | "
|
|
f"Base: {colors['bg']} / {colors['fg']}"
|
|
)
|
|
info_label = ttk.Label(tab_frame, text=info_text)
|
|
info_label.pack(pady=5)
|
|
|
|
print("Test window created. Check header visibility in different themes.")
|
|
root.mainloop()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_improved_headers()
|