[IPython-dev] Help! TR: TR: Ipython plugin
Mon Jun 2 15:39:32 CDT 2008
[Warning very long mail that do a sum-up(?) of all problem I encoutered to
make an ipython0 gui interaction]
About specific API for GUI devs,
Here is my feeling about what was missing in ipython0 and that could be
refactored/improved while switching to ipython1:
- stdin/stdout/stderr hook (the MOST important):
All ipython0 is tightly glued with pyreadline that is not tailored for
'graphical' gui (from my point of view ^_^):
We should think about an API where we could send data we get from user:
(ip_output,ip_error) = IP.IO.process_input(user_input)
I mean we can stay with pyreadline for console based terminal but I think we
need something simpler for "graphical" gui.
Pyreadline is thought to handle all user key and process input/output for
In a GUI the designer is using a specific widget he has choosed and handle
its user input the way he want.
So pyreadline is something too much complex for what I needed.(I only use
the ASCII coloration output of pyreadline)
(Another time, this is my point of view, some other devs will say that this
is the job of a readline object: I'm not ok with that because I want to be
free and I need something flexible. "Keep it simple" philosophy)
By the way it could be interesting to have something like what pyreadline is
doing but improved:
IP.IO.setOutFilter("html") or IP.IO.setOutFilter("ANSI") that output the
result as a 'html' or 'xml' or 'ascii_colored' or user_defined filter hook.
My main problems were:
#we replace the ipython default pager by our pager
#we replace the ipython default shell command caller by our shell
#we replace the ipython default input command caller by our method
IPython.iplib.raw_input_original = self._raw_input
#we replace the ipython default exit command by our method
self._IP.exit = ask_exit_handler
#we replace the help command
self._IP.user_ns['help'] = _Helper(self._pager_help)
Most of these lines where mostly ugly hack that could have been avoid if I
had the IP.process_input and IP.get_output command.
IP.IO.process_input(user_input) <-- this is really important! See 'def
_execute(self):' in ipshell_nonblocking to see how I handle that.
We can't ask people that want to integrate a new GUI toolkit to write this
sort of code. They will run away ;). Hopefully I've totally copied it from
GTK port :), that's why I didn't ran away ^_^
- history management API simpler(my current problem):
Currently ipython history is completely handled by pyreadline. I feel
ipython0 is missing an history API simpler.
In fact this is something I can get from pyreadline, but it is really
complex. I need to access the readline object and then call some function of
function of readline API.
Can be simpler for ipython0 external user. So perhaps this is just some
wrapper around pyreadline to hide the complexity to external and non
It was so complex for me (based on my poor knowledge of ipython0 and
pyreadline) that it was simpler to make my history API.
(And this was also the case with gtk port from which I based my work).
- Completer API.
IP.Completer.getCompletion(user_input_to_complete) -> return a list of
Check complete function of ipshell_nonblocking to see how I(hum perhaps
previous guy in fact :) ) did a simpler thing.
That all for the moment ;)
More information about the IPython-dev