##// END OF EJS Templates
new completer for qtconsole....
new completer for qtconsole. add a completer to the qtconsole that is navigable by arraow keys and tab. One need to call it twice to get it on focus and be able to select completion with Return. looks like zsh completer, not the gui drop down list of --gui-completer. This also try to split the completion logic from console_widget, and try to keep the old completer qui around. The plain completer that never takes focus back, and the QlistWidget completer. to switch between the 3, the --gui-completion flag as been changed to take an argument (plain, droplist, ncurses).

File last commit:

r7211:49a9eba4
r7389:1422d277
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')