From 4ba155bb683cb71e85ba816ab6aeef83582e4496 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Wed, 18 Dec 2024 10:43:30 +0000 Subject: [PATCH] Docstrings --- docs/widgets/select.md | 1 - src/textual/widgets/_select.py | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/widgets/select.md b/docs/widgets/select.md index ec1e12b2b1..aabd7d2970 100644 --- a/docs/widgets/select.md +++ b/docs/widgets/select.md @@ -98,7 +98,6 @@ The `Select` widget has a `type_to_search` attribute which allows you to type to ## Reactive Attributes - | Name | Type | Default | Description | |------------|--------------------------------|------------------------------------------------|-------------------------------------| | `expanded` | `bool` | `False` | True to expand the options overlay. | diff --git a/src/textual/widgets/_select.py b/src/textual/widgets/_select.py index a76b906033..0c31652d90 100644 --- a/src/textual/widgets/_select.py +++ b/src/textual/widgets/_select.py @@ -63,13 +63,21 @@ class UpdateSelection(Message): def __init__(self, type_to_search: bool = True) -> None: super().__init__() self._type_to_search = type_to_search + """If True (default), the user can type to search for a matching option and the cursor will jump to it.""" + self._search_query: str = "" + """The current search query used to find a matching option and jump to it.""" + + self._search_reset_delay: float = 0.7 + """The number of seconds to wait after the most recent key press before resetting the search query.""" def on_mount(self) -> None: def reset_query() -> None: self._search_query = "" - self._search_reset_timer = Timer(self, 0.7, callback=reset_query) + self._search_reset_timer = Timer( + self, self._search_reset_delay, callback=reset_query + ) def watch_has_focus(self, value: bool) -> None: self._search_query = ""