[IPython-dev] Multiline editing in a qtconsole-style app

Osborn, Raymond rosborn at anl.gov
Sun Nov 29 09:47:52 EST 2015


Thanks for your reply. My inheritance chain includes the console_widget, so I have access to the _is_complete function, but it looks like I might have a different problem.

I’ve been running this through my debugger again, and if I set ‘execute_on_complete_input’ to False, it doesn’t call the _is_complete function and assumes everything is complete. The shell then works apart from multiline editing.

However, if I set ‘execute_on_complete_input’ to True (the default), then it calls the _is_complete function, sends an ‘is_complete’ request to the frontend, but never gets a reply. It calls the get_msg function in jupyiter_client/blocking/channels.py, but this always raises Empty. Sometimes the debugger causes timeout problems, but even when I remove all the breakpoints except for call to self._recv, it is never triggered, and this seems to explain why no lines in the shell are recorded as complete.

I’ll see if I can reproduce this chain in the IPython qtconsole.

Ray


On Nov 29, 2015, at 6:22 AM, Thomas Kluyver <takowl at gmail.com<mailto:takowl at gmail.com>> wrote:

Hi Ray,

On 28 November 2015 at 21:08, Osborn, Raymond <rosborn at anl.gov<mailto:rosborn at anl.gov>> wrote:
However, I only just noticed that we seem to have lost the ability to do multiline editing, without using the Ctrl key modifier. Even with the modifier, the indent is not correctly set, so the behavior has diverged from the ipython qtconsole, where multiline editing is automatic if the code is not complete and a proper indent is set.

I think I know what you're running into. In previous versions of the Qt console, the frontend decided whether to prompt for another line and how much to indent it by processing the Python code that was typed in. As we've moved towards supporting multiple languages, it's not appropriate for the frontend to make that decision, so it has to ask the kernel about it. It does that by making is_complete_request to the kernel:
http://jupyter-client.readthedocs.org/en/latest/messaging.html#code-completeness

Assuming you're using the Qt console with an IPython kernel, it should still be straightforward to use that, but I guess it needs some changes in your integration code to make sure the message gets through. The widget object now has an is_complete method, which you can see here:
https://github.com/jupyter/qtconsole/blob/f2c8a31c387ce1e020ccdbb020091de2ee98dbf9/qtconsole/frontend_widget.py#L260

Best wishes,
Thomas
_______________________________________________
IPython-dev mailing list
IPython-dev at scipy.org<mailto:IPython-dev at scipy.org>
https://mail.scipy.org/mailman/listinfo/ipython-dev

--
Ray Osborn, Senior Scientist
Materials Science Division
Argonne National Laboratory
Argonne, IL 60439, USA
Phone: +1 (630) 252-9011
Email: ROsborn at anl.gov<mailto:ROsborn at anl.gov>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20151129/778b2897/attachment.html>


More information about the IPython-dev mailing list