#!/usr/bin/env python3 """ Simple test to trace button creation without running full TUI """ import sys from pathlib import Path # Add analyzer to path sys.path.insert(0, str(Path(__file__).parent)) from analyzer.tui.textual.widgets.filtered_flow_view import FilteredFlowView from analyzer.analysis.core import EthernetAnalyzer def test_button_creation(): """Test button creation step by step""" print("🧪 Testing Button Creation Step-by-Step") print("=" * 50) # Create analyzer print("1. Creating analyzer...") analyzer = EthernetAnalyzer() # Create FilteredFlowView print("2. Creating FilteredFlowView...") try: view = FilteredFlowView(analyzer) print(" āœ… FilteredFlowView created successfully") print(f" āœ… Initial buttons dict: {len(view.frame_type_buttons)} entries") for name, btn in view.frame_type_buttons.items(): print(f" - {name}: {btn}") except Exception as e: print(f" āŒ Failed to create FilteredFlowView: {e}") import traceback traceback.print_exc() return False # Test predefined frame types print("3. Checking predefined frame types...") print(f" āœ… Predefined types: {view.predefined_frame_types}") # Test compose method (this is where buttons should be created) print("4. Testing compose method...") try: # This would normally be called by Textual, but we can't easily test it # without the full TUI framework print(" āš ļø Compose method can't be tested without TUI framework") print(" ā„¹ļø This is where buttons should be created during widget composition") except Exception as e: print(f" āŒ Compose method failed: {e}") # Test refresh_frame_types print("5. Testing refresh_frame_types...") try: # This should be safe to call even without TUI view.refresh_frame_types() print(" āœ… refresh_frame_types completed without error") except Exception as e: print(f" āŒ refresh_frame_types failed: {e}") import traceback traceback.print_exc() return True def main(): print("šŸ” Simple Debug Test for Button Issues") print("This test checks button creation logic without running the full TUI") print("=" * 60) success = test_button_creation() if success: print("\nāœ… Basic components created successfully") print("\nšŸŽÆ Key Findings:") print(" • FilteredFlowView can be instantiated") print(" • Predefined frame types are configured") print(" • refresh_frame_types can be called") print("\nšŸ’” Next Steps:") print(" • The issue likely occurs during compose() or on_mount()") print(" • These methods interact with the Textual widget system") print(" • Need to debug within the running TUI app") else: print("\nāŒ Issues found in basic component creation") if __name__ == "__main__": main()