[IPython-dev] Multiline editing in a qtconsole-style app
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
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 = ''
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,
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.
IPython-dev mailing list
IPython-dev at scipy.org<mailto:IPython-dev at scipy.org>
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...
More information about the IPython-dev