[IPython-user] pyreadline, code.InteractiveConsole and tab completion on Windows

Jörgen Stenarson jorgen.stenarson@bostream...
Tue Apr 7 14:52:40 CDT 2009


Thomas Heller skrev:
> Jörgen Stenarson schrieb:
>> Thomas Heller skrev:
> My Python console isn't started in the usual way because my application is
> a Windows application.
> When a certain button is pressed in the GUI, a win32 console is allocated,
> sys.std[in|out|err] are initialized to readers/writers that read and write to
> from/to the corresponding console handles, and so on.  Basically the code goes
> like this:
> 
>     windll.kernel32.AllocConsole()
>     windll.kernel32.SetConsoleTitleA(str(title))
> 
>     sys.stdout = writer(windll.kernel32.GetStdHandle(-11))
>     sys.stderr = writer(windll.kernel32.GetStdHandle(-12))
>     sys.stdin = reader(windll.kernel32.GetStdHandle(-10))
> 
out of curiosity what is reader and writer?

>     from code import InteractiveConsole
> 
>     console = InteractiveConsole(ns)
>     console.interact(title)
> 
> reader(handle) and writer(handle) are instances that read and write from/to
> the console handles with the windll.kernel32.WriteConsole[A|W]()
> and windll.kernel32.ReadConsoleW() windows functions.
> So, is it possible to plug pyreadline into this system somehow?
> 

I have no idea if it is possible. I'm sorry to say this is at the edge 
of my comfort level in win32 programming.

Something to investigate would be to see if you can patch in a handle to 
your console in the active Console object. It can be found in 
readline.rlmain.rl.console. Check the __init__ method of Console in 
readline.console.console.py to see what configurations are done on startup.

If you have any ideas on how to change things to make it more useful for 
you please let me know.

/Jörgen



More information about the IPython-user mailing list