Skip to main content

Add search to Textual SelectionList.

Project description

Searchable SelectionList

image Project License - MIT

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

textual_searchable_selectionlist-0.0.8.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Hashes for textual_searchable_selectionlist-0.0.8.tar.gz
Algorithm Hash digest
SHA256 6c9e6e2f4e380a8b91f5e43a8d29ddc3089c1ca1e52746f9648af2e1aad5e9dd
MD5 ddfadbf307783c577aa5f42924dbffd8
BLAKE2b-256 fc8ff0a56f8a9fdb3a6a99fc9f18d9822c1eb9ab6e28c6a10d4a0a768dba5130

See more details on using hashes here.

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

Hashes for textual_searchable_selectionlist-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 05cf9dbd452f3b2c460eeba0f64a3841741736a1f72436460c3281e3ffef989f
MD5 a51a2e77dfd502d46d40715d786d20f9
BLAKE2b-256 ae457e3ac82b07c4cd8d5042added7588804e986d0827fc12226240f5cab0f63

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page