[IPython-dev] Non-blocking interact() for GUI/IPython1 use
Ville M. Vainio
vivainio at gmail.com
Fri Feb 1 11:51:14 EST 2008
In the interest of making ipython trunk more likely to fit into the
ipython1 framework, I made the blocking raw_input read_eval_print
optional.
I created
def interact_prompt(self):
...
def interact_handle_input(self,line):
...
These can be used to create GUIs (that of course want to handle their
own input-waiting) for IPython.
Here is a demo on how to use it, but of course this demo uses plain
old readline and blocking raw_input:
def interact_with_readline(self):
""" Demo of using interact_handle_input, interact_prompt
This is the main read-eval-print loop. If you need to
implement your own (e.g. for GUI),
it should work like this.
"""
self.readline_startup_hook(self.pre_readline)
while not self.exit_now:
self.interact_prompt()
if self.more:
self.rl_do_indent = True
else:
self.rl_do_indent = False
line = raw_input_original().decode(self.stdin_encoding)
self.interact_handle_input(line)
Currently, interact_with_readline() is not called in IPython, but it
works pretty much exactly like the standard interact().
--
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'
More information about the IPython-dev
mailing list