AttributeError: 'Screen' object has no attribute '_select_start' (missing private API attribute)
Bug Description
When accessing screen._select_start in a monkey-patched auto-scroll handler, an AttributeError is raised because the _select_start attribute no longer exists on the Screen class in recent Textual versions.
AttributeError: 'Screen' object has no attribute '_select_start'
Environment
- OS: Linux-5.15.0-173-generic-x86_64-with-glibc2.35
- Python: 3.10.12 (main, Mar 3 2026, 11:56:32) [GCC 11.4.0]
- Textual: 8.2.6
- Arch: x86_64
Analysis
The code accessing screen._select_start was:
if screen._select_start is not None:
sw = screen._select_start[0] # expected tuple[Widget, Offset]
In Textual 8.2.6, Screen class no longer has a _select_start attribute. The old _select_start appears to have been a tuple[Widget, Offset] (widget + offset pair).
Searching the whole Textual 8.2.6 codebase shows ZERO occurrences of _select_start — it has been fully removed.
Current Screen selection API (Textual 8.2.6)
The Screen class now uses:
_select_state: Reactive[SelectState | None]— aSelectState(NamedTuple)containing:start: SelectStart— with fields:container: Widget,container_pointer_delta: Offset,container_initial_offset: Offset,container_initial_scroll_offset: Offset,content_widget: Widget | None,content_offset: Offset | Noneend: SelectEnd | None
selections: var[dict[Widget, Selection]]— map of widgets and selected ranges_selecting: var(False)— boolean indicating selection in progress_auto_select_scroll_timer: Timer | None— timer for auto-scroll during selection_auto_select_scroll(self, direction, speed)— method that handles auto-scroll_update_select(self)— method to update selection for screen-space offset
Suggested Fix
Replace the old _select_start attribute access with the new _select_state API:
# Old code (raises AttributeError):
if screen._select_start is not None:
sw = screen._select_start[0]
# New code (compatible with current API):
if screen._select_state is not None:
sw = screen._select_state.start.content_widget or screen._select_state.start.container
else:
sw = widget # fallback
Additional Notes
_select_startwas a private API that was removed during the text selection refactor.- The current private API uses
_select_state(of typeSelectState | None) instead. - Public APIs like
screen\.selections,screen\.get_selected_text(), andaction_copy_text()remain available and unchanged.
Thank you for your issue. Give us a little time to review it.
PS. You might want to check the FAQ if you haven't done so already.
This project is developed and maintained by Will McGugan. Consider sponsoring Will's work on this project (and others).
This is an automated reply, generated by FAQtory
I hope I solved your issue!
Consider sponsoring my work to continue to maintain and develop Textual.
- Will McGugan
Did your clanker monkey patch a private variable?