##// END OF EJS Templates
Don't reset the readline completer after each prompt...
Don't reset the readline completer after each prompt This makes it impossible to setup a custom completer. The comment says that "we must ensure that our completer is back in place," but I don't see why. All that does it make it impossible to use a different completer. One can trick IPython into not doing this by monkeypatching ip.has_readline to False, but then certain features like multiline editing are no longer enabled. See https://github.com/davidhalter/jedi/pull/321.

File last commit:

r9190:20a102a5
r12906:1363065e
Show More
widget.py
58 lines | 1.6 KiB | text/x-python | PythonLexer
"""Python support code for JavaScript based widgets.
Authors:
* Brian Granger
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008-2012 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import os
import uuid
from IPython.core.display import display, Javascript
from zmq.utils import jsonapi
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
class JavascriptWidget(object):
jslibs = []
def __init__(self):
self.widget_id = unicode(uuid.uuid4()).replace('-','')
self.widget_var = '__widget_%s' % self.widget_id
ns = get_ipython().user_ns
ns[self.widget_var] = self
def encode_json(self, o):
return jsonapi.dumps(o)
def decode_json(self, s):
return jsonapi.loads(s)
def interact(self):
"""This should call display(Javascript(jscode))."""
jscode = self.render()
display(Javascript(data=jscode,lib=self.jslibs))
def render(self):
"""Return the final JavaScript code that will be eval'd in the client."""
raise NotImplementedError('render is not implemented in this base class')