1
0
Fork 0

Adding upstream version 4.0.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-04 22:09:41 +02:00
parent 1f832614e9
commit 0832c185c0
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
48 changed files with 7595 additions and 0 deletions

38
examples/dynamic_data.py Normal file
View file

@ -0,0 +1,38 @@
from textual.app import App, ComposeResult
from textual.widgets import Input
from textual_autocomplete import AutoComplete
from textual_autocomplete._autocomplete import DropdownItem, TargetState
class DynamicDataApp(App[None]):
CSS = """
Input {
margin: 2 4;
}
"""
def compose(self) -> ComposeResult:
input_widget = Input()
yield input_widget
yield AutoComplete(input_widget, candidates=self.get_candidates)
def get_candidates(self, state: TargetState) -> list[DropdownItem]:
left = len(state.text)
return [
DropdownItem(item, prefix=f"{left:>2} ")
for item in [
"Apple",
"Banana",
"Cherry",
"Orange",
"Pineapple",
"Strawberry",
"Watermelon",
]
]
if __name__ == "__main__":
app = DynamicDataApp()
app.run()