#!/usr/bin/env python3 """Test script to verify theme changing functionality works without errors.""" 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.parent / "src" sys.path.insert(0, str(src_path)) def test_theme_changes(): """Test changing between different themes to ensure no errors occur.""" print("Testing theme changing functionality...") # Create a test tkinter window root = tk.Tk() root.withdraw() # Hide the window # Initialize theme manager theme_manager = ThemeManager(root, logger) # Test all available themes available_themes = theme_manager.get_available_themes() print(f"Available themes: {available_themes}") for theme in available_themes: print(f"Testing theme: {theme}") try: success = theme_manager.apply_theme(theme) if success: print(f" ✓ {theme} applied successfully") # Test getting theme colors (this is where the error was occurring) colors = theme_manager.get_theme_colors() print(f" ✓ Theme colors retrieved: {list(colors.keys())}") # Test getting menu colors menu_colors = theme_manager.get_menu_colors() print(f" ✓ Menu colors retrieved: {list(menu_colors.keys())}") else: print(f" ✗ Failed to apply {theme}") except Exception as e: print(f" ✗ Error with {theme}: {e}") # Clean up root.destroy() print("Theme testing completed!") if __name__ == "__main__": test_theme_changes()