##// END OF EJS Templates
Merge pull request #2179 from dopplershift/pylab-switch...
Merge pull request #2179 from dopplershift/pylab-switch Enable switching %pylab mode between inline and a single gui mode in a single notebook. With this merge, `%pylab` can be called interactively to toggle inline/GUI (matplotlib floating windows) mode. After initializing `%pylab inline`, now one can call `%pylab` without arguments to activate the default GUI or ask for a specific one as usual. IPython will detect if a different GUI is requested if one was already activated and will refuse to do so (to prevent multiple event loops from running concurrently, which often leads to problems).

File last commit:

r7211:49a9eba4
r8027:6dac6929 merge
Show More
directview.py
68 lines | 1.8 KiB | text/x-python | PythonLexer
"""Widget for interacting with an IPython parallel engine.
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 IPython.core.displaypub import publish_pretty
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
import os, sys
from IPython.core.display import Javascript
from widget import JavascriptWidget
class DirectViewWidget(JavascriptWidget):
def __init__(self, dv):
self.dv = dv
self.targets = self.dv.targets
super(DirectViewWidget,self).__init__()
def render(self):
fname = os.path.join(os.path.dirname(__file__), u'directview.js')
with open(fname, 'r') as f:
jscode = f.read()
data = {
'widget_var': self.widget_var,
'targets' : self.encode_json(self.targets)
}
jscode = jscode % data
return jscode
def execute(self, code, targets='all'):
if targets == 'all':
targets = self.targets
result = self.dv.execute(code,silent=False,block=False,targets=targets)
result.wait()
result.display_outputs()
def interact(dv):
w = DirectViewWidget(dv)
w.interact()
return w