Add search to Textual SelectionList.
Project description
Searchable SelectionList
Add search to Textual's SelectionList.
- Selectable items can be filtered by substring.
- Select one or multiple items.
- Search is case-insensitive.
- Title and description can be customized.
Installation
pip install textual-searchable-selectionlist
Usage
from textual_searchable_selectionlist.options import SelectionStrategy
from textual_searchable_selectionlist.select import select, select_enum
selected = select(
['John', 'Jane', 'James'],
selection_strategy=SelectionStrategy.MULTIPLE,
search_title='Select people',
)
# Enums
# class Color(Enum):
# RED = 'red'
# GREEN = 'green'
#
# selected_colors = select_enum(Color, selection_strategy=SelectionStrategy.ONE)
Events and callbacks
Use selected_callback when embedding the widget, or listen for the
SearchableListWidget.Selected message in your app.
from textual.app import App, ComposeResult
from textual_searchable_selectionlist.options import SelectionStrategy
from textual_searchable_selectionlist.searchable_list_widget import SearchableListWidget
class MyApp(App):
def compose(self) -> ComposeResult:
yield SearchableListWidget(
"Alpha",
"Beta",
"Gamma",
selection_strategy=SelectionStrategy.ONE,
selected_callback=self._on_selected_callback,
)
def _on_selected_callback(self, selected: list[str]):
self.log(f"Callback selected: {selected}")
def on_searchable_list_widget_selected(
self, event: SearchableListWidget.Selected
):
self.log(f"Event selected: {event.selected}")
Development and testing
Make sure uv is installed globally.
There are currently no automated tests. Manual testing can be done by running:
python tests/manual/searchable_selection_list_select.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file textual_searchable_selectionlist-0.0.8.tar.gz.
File metadata
- Download URL: textual_searchable_selectionlist-0.0.8.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c9e6e2f4e380a8b91f5e43a8d29ddc3089c1ca1e52746f9648af2e1aad5e9dd
|
|
| MD5 |
ddfadbf307783c577aa5f42924dbffd8
|
|
| BLAKE2b-256 |
fc8ff0a56f8a9fdb3a6a99fc9f18d9822c1eb9ab6e28c6a10d4a0a768dba5130
|
File details
Details for the file textual_searchable_selectionlist-0.0.8-py3-none-any.whl.
File metadata
- Download URL: textual_searchable_selectionlist-0.0.8-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05cf9dbd452f3b2c460eeba0f64a3841741736a1f72436460c3281e3ffef989f
|
|
| MD5 |
a51a2e77dfd502d46d40715d786d20f9
|
|
| BLAKE2b-256 |
ae457e3ac82b07c4cd8d5042added7588804e986d0827fc12226240f5cab0f63
|