- Fixed DataTable row selection and event handling - Added explicit column keys to prevent auto-generated keys - Implemented row-to-flow mapping for reliable selection tracking - Converted left metrics panel to horizontal top bar - Fixed all missing FlowStats/EnhancedAnalysisData attributes - Created comprehensive Textual API documentation in Documentation/textual/ - Added validation checklist to prevent future API mismatches - Preserved cursor position during data refreshes - Fixed RowKey type handling and event names The TUI now properly handles flow selection, displays metrics in a compact top bar, and correctly correlates selected rows with the details pane.
Textual API Reference
This directory contains a comprehensive reference for the Textual library API, focusing on the components used in StreamLens.
Overview
Textual is a TUI (Text User Interface) framework for Python. This reference covers the key APIs we use.
Quick Links
- DataTable Widget Reference - Complete DataTable API
- Events Reference - Event handling and messages
- Common Widgets - Other widgets used in StreamLens
- Styling Guide - CSS and styling reference
Core Concepts
Messages and Events
Textual uses a message-passing system for communication between widgets:
- Events - User interactions (keyboard, mouse)
- Messages - Widget-to-widget communication
- Handlers - Methods that respond to events/messages
Event Handler Naming
Event handlers follow the pattern: on_<widget_class>_<event_name>
Example:
def on_data_table_row_selected(self, event: DataTable.RowSelected):
# Handle row selection
Common Pitfalls
- RowKey Type: DataTable row keys are not strings by default
- Event Names: Check exact event class names (e.g.,
RowHighlightednotCursorMoved) - Method Availability: Not all expected methods exist (e.g., no
set_row_style())
API Validation
Always validate API usage before implementation:
# Check available events
from textual.widgets import DataTable
print([attr for attr in dir(DataTable) if 'Selected' in attr or 'Highlighted' in attr])
# Check specific method
print(hasattr(DataTable, 'method_name'))
Directory Structure
datatable.md- Complete DataTable API referenceevents.md- Events and message handlingwidgets.md- Common widget APIsstyling.md- CSS and themingexamples/- Working code examples