Nobody has recommended prompt_toolkit (TUI only) yet, so here I go:
https://python-prompt-toolkit.readthedocs.io/en/master/
I'm working on an interface for an LLM (large language model), and prompt_toolkit seems to be the only library with enough text-buffer features for me to implement everything I want.
It's quite imperative-feeling though. Have to keep references to individual widgets if you want to do anything with them later.