readline() support in Text widget?
Getting readline() working in a terminal app is trivially easy:
import readline
Now calls to input()/raw_input() have readline support. Done.
But I want to make a graphical app that happens to have a large text input area. I want readline() to work in that text area. I'm not seeing how to make this work.
I thought idle probably did something similar, but there's two problems there. First, it turns out it doesn't support readline(). But even if it did, it is implementing basically an entire shell/editor window from scratch. I don't really want to do that either.
The simplest thing to do would be to embed an xterm inside my app and run the simple terminal readline() program inside it. But then how do I communicate the commands inside the terminal to the surrounding graphical app? Sockets? Seems a little hokey. But it's the only thing I've thought of.
Any ideas?
Posted Nov 16, 2018, 2:53 PM UTC
Not an answer to your question, but why do you need readline module to get readline support. Like input() already reads lines so what is it’s purpose
Really nice editing with hotkeys and history are killer features. In fact, I'm basically working with 1.5 hands tied behind my back without them.
I still have no idea why you’re using the readline module
Write a simple REPL-like program using
raw_input(). Start typing. Then pressC-a, thenC-k.Now put
import readlineat the top and try it again.I think you're perhaps a little too focused on one specific tool here, and phrasing the question oddly as a result.
What I think you're really asking is:
Is that correct? Or do you actually have to use readline specifically, for some reason?
Well maybe. I mean, yes, I could write all that functionality from scratch...but I'm not going to. It has to exist already. It doesn't have to be literal
readline()I guess, but it'll have to be a drop in replacement from the user's POV.