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

Osborn, Raymond rosborn at anl.gov
Sun Nov 29 15:36:58 EST 2015


After a lot of digging through the weeds, it turned out that the answer was surprisingly simple. As you suggested, the machinery is all there.

I had to subclass the RichJupyterWidget to handle calls to ‘_is_complete':

from qtconsole.rich_jupyter_widget import RichJupyterWidget

class NXRichJupyterWidget(RichJupyterWidget):

    def _is_complete(self, source, interactive=True):
        shell = self.kernel_manager.kernel.shell
        status, indent_spaces = shell.input_transformer_manager.check_complete(source)
        if indent_spaces is None:
            indent = ''
        else:
            indent = ' ' * indent_spaces
        return status != 'incomplete', indent

I’m not sure if this is appropriate for a pull request, because I don’t know where you would put the above code. Perhaps the RichJupyterWidget could be subclassed in qtconsole/inprocess.py, since my solution is specific to the in-process kernel.

If you can see any other problems with the above, please let me know. I would like to issue a fix to NeXpy, as long as I’ve understood all its implications.

Thanks for your guidance,
Ray

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

On 29 November 2015 at 17:27, Osborn, Raymond <rosborn at anl.gov<mailto:rosborn at anl.gov>> wrote:
It occurs to me that I should mention that I’m using the inprocess kernel. I am wondering if the ‘is_complete’ request is trying to be sent to a real socket rather than the dummy socket that the inprocess client is using. Perhaps I have to reassign the blocking client it uses for such requests.

Aha. The inprocess kernel is decidedly unloved, and it may well cause problems with this. I seem to remember Min saying something about this.

On the plus side, the in process kernel has to be Python, so it would be practical to reuse the kernel machinery to determine completeness.

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/c04c0d2b/attachment.html>


More information about the IPython-dev mailing list