Update SelectionList based on Input submission #5621
-
Hey there! Say I have a The I've been looking into using the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @AndyDralle, Something like this will work after the user presses the enter key: from textual.app import App, ComposeResult
from textual.widgets import SelectionList, Input
class SandboxApp(App[None]):
def compose(self) -> ComposeResult:
yield Input()
yield SelectionList(
("fizz", "fizz"),
("buzz", "buzz"),
("foo", "foo"),
)
def on_input_submitted(self, message: Input.Submitted) -> None:
self.query_one(SelectionList).select(message.value)
message.input.clear()
if __name__ == "__main__":
SandboxApp().run() Could validate the selection more or remove the clear method if the previous value is required after. |
Beta Was this translation helpful? Give feedback.
Hi @AndyDralle,
Something like this will work after the user presses the enter key:
Could validate the selection more or remove the clear method if the previous value is requ…