[IPython-dev] new wxIPython version 0.4.(polished,polished!)

laurent.dufrechou at free.fr laurent.dufrechou at free.fr
Mon Dec 10 05:39:28 EST 2007

Hi Jörgen,All,

I've updated the app this week-end and it now supports a threaded IPython :)
So Ctrl+C works now, also the '!' commands works too.
It was a little bit tricky because it is not easy to raise an asynchronous
KeyboardInterrupt inside another thread.
Hopefully I've found on the net a little piece of code that do it :)
Things remaining are autoindent that still doesn't want to work, tab completion
behavior that don't work on some case ( a=smtplib.+TAB don't work) and the
strange bug with:
Class a:
	Def a():
The next line always fail with syntax error... (classical IPython shell work)

I will release the new version soon, I want before to check some glitch on the
new pager.

>From my point of view, the things that were missing where first not so
pyreadline related in fact.
Because I used the function provided by IPython, I could find the history. I
admit it would have been more easier if there was inside IPython something like
historyBack, historyForward, getHistoryLength, setHistoryPos(pos).
The hardest thing was to find what function needed to be redefined:
IPython.genutils.page_dumb, IPython.iplib.raw_input, IPython.Shell.Term.cout
/cin/cerr, IPython.genutils.shell_ori and
self._IP.stdin_encoding, self._IP.exit.

What my gui needed was (If I don't forget anything):
getPromptCount (to get the number of prompt)
getPrompt (to get the prompt)
getPromptLengthRaw (with no colors text)<-- can be handled by pyreadline
complete (to get completion list) <-- can be handled by pyreadline to format it
knowing the width of the widget
removeCurrentPrompt() that remove multiple line until start of curren prompt
write() that handle ansi colors <-- can be handled by pyreadline, but GUI
toolkit related...
getCurrentLineEnd() goes to end of buffer
and finally a protection system for the colored text. <-- hum... don't know if
could be pyreadline related, sure there could be a mechanism were pyreadline has
property buffer that I could ask to check the color of a position and it it is
protected or not :) (could be REALLY usefull)
(Currently to do protection I check if the color is white on black :) )

I still miss autoindent, but I try to use it via IPython instance, so I think
pyreadline will not be necessary on my side but more on IPython side.(that is
mostly hidden for me)

The problem is that most of these function are widget related and tightly
related to the GUI library you use.
So I don't know if it is more a pyreadline problem or a GUI designer problem...

I think, (well on how I've used IPython instance and that can be done
differently) that pyreadline was hiddent inside IPython. Pyreadline can be very
usefull if I had reimplemented the IPython loop but as I've reused an IPython
object and communicate with it via cin/cout/cerr all the pyreadline magic was
hidden inside IPython. I was only reusing the pyreadline reformated cout in

For the copy/paste it was directly handled by the widget I derivate(?) so didn't
need pyreadline there too.(but can be a good idea for other widget/toolkit).

For the auto-indent, here I will really need pyreadline, because I send a
command to IPython and if it returns a prompt it could (I think) be very usefull
if I could ask pyreadline how much tab I need to had to it. And this is a
function that is still missing for me (perhaps it exists, and I 've not found it
for the moment).

So to conclude,
--> Property buffer to keep track of a property of a position (hummm, perhaps
hard to do...)
--> getIndentation function (really need it)
--> getFormatedCompletion(size)

Could be very useful for me!
I will take a look at the console backend...
Ok I've just done it :)
Humm seems that in fact it looks like what I've done in my WxConsoleView class!
Perhaps we could adapt it to integrate well with pyreadline??? (And make then a


More information about the IPython-dev mailing list