[IPython-dev] Experimental GLUT integration

Fernando Perez fperez.net at gmail.com
Tue Sep 13 16:14:00 EDT 2011

Hi Nicolas,

On Tue, Sep 13, 2011 at 4:39 AM, Nicolas Rougier
<Nicolas.Rougier at inria.fr> wrote:
> I'm still fighting against glut and I would have one question:
> To make things work, I need to intercept SIGINT and to print explicitly 'KeyboardInterrupt' and then reprint the prompt.
> What is the best way to reprint the current prompt ?

odd as it sounds, there's no simple, clean way to reprint the current
prompt (at least not in fully formatted form in color).  You can get
it with

ip = get_ipython()
prompt = ip.hooks.generate_prompt(False)

but that string has embedded characters that for some reason mess up
the line if you print them directly, though they show up correctly if
passed as an argument to raw_input(prompt), which is how we actually
use it.

But I think it's ok if you simply print 'KeyboardInterrupt'.  We
already have other cases where this happens, and I think we're all
used to just hitting Enter at that point, which cleanly redraws the

Not ideal, but it should do for now.  One of our big todo items is
certainly a full restructuring of our prompt management machinery (for
which PR #507 is a start), but you don't need to wait for that to



More information about the IPython-dev mailing list