Skip to content

Instantly share code, notes, and snippets.

@vpmartin
vpmartin / searchableselect.py
Last active November 4, 2024 03:11
A SearchableSelect widget for Textual, that's composed of an Input and an OptionList, and acts as a regular Select widget. Allows searching for items in the options, which is not possible with the base Select widget.
from typing import Any
from textual.containers import Vertical, VerticalScroll
from textual.widgets import Select, OptionList, Input
from textual.widgets.option_list import Option
from textual.validation import Validator, ValidationResult
class InputInOptions(Validator):
"""An `Input` validator that checks if the input is part of a list."""