mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Suggestion autocomplete scrolls if required
This commit is contained in:
@@ -20,10 +20,10 @@ words = set(Path("/usr/share/dict/words").read_text().splitlines())
|
||||
|
||||
|
||||
def word_autocompleter(value: str) -> str | None:
|
||||
print(value)
|
||||
# An example autocompleter that uses the Unix dictionary to suggest
|
||||
# word completions
|
||||
for word in words:
|
||||
if word.startswith(value):
|
||||
print("autocompleter suggests: ", word)
|
||||
return word[len(value) :]
|
||||
return None
|
||||
|
||||
@@ -36,6 +36,11 @@ class InputApp(App[str]):
|
||||
text_boxes = Widget(self.fahrenheit, self.celsius)
|
||||
self.mount(inputs=text_boxes)
|
||||
self.mount(spacer=Widget())
|
||||
self.mount(
|
||||
top_search=Widget(
|
||||
TextInput(autocompleter=word_autocompleter, id="topsearchbox")
|
||||
)
|
||||
)
|
||||
self.mount(
|
||||
footer=TextInput(
|
||||
placeholder="Footer Search Bar", autocompleter=word_autocompleter
|
||||
|
||||
@@ -37,12 +37,17 @@ Screen {
|
||||
dock: bottom;
|
||||
}
|
||||
|
||||
#top_search {
|
||||
dock: top;
|
||||
}
|
||||
|
||||
#topsearchbox {
|
||||
width: 10;
|
||||
}
|
||||
|
||||
#footer {
|
||||
background: $primary-darken-2;
|
||||
dock: bottom;
|
||||
height: 1;
|
||||
border: ;
|
||||
}
|
||||
|
||||
#footer :focus {
|
||||
border: heavy $secondary;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user