0

I'm using the Textual-framework in Python and I want the user to enter a multiline Text. However, I cannot find a widget that does the trick.

With the Input widget on can only enter one line. I tried to tweak it, but I cannot fix it so it wraps the text, when it overflows. Here is a minimal example. I also tried the overflow style, but it doesn't work.

from textual.app import App
from textual.binding import Binding
from textual.widgets import Input


class MultiLineInput(Input):
    BINDINGS = [Binding("enter", "newline", "New line", show=True)]

    def action_newline(self):
        self.value += "\n"
        self.cursor_position = len(self.value)

    def on_mount(self):
        self.styles.height="4"


class Minimal(App):
    def compose(self):
        yield MultiLineInput(id="input")


if __name__ == "__main__":
    app = Minimal()
    app.run()

1 Answer 1

1

See the new Textual TextArea widget.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.