##// END OF EJS Templates
Fix typo
Martin Spacek -
Show More
@@ -1,59 +1,59
1 1 #-----------------------------------------------------------------------------
2 2 # Imports
3 3 #-----------------------------------------------------------------------------
4 4
5 5 import subprocess
6 6 import sys
7 7
8 8 from IPython.lib.kernel import connect_qtconsole
9 from IPython.kernel.zmq.ipkernel import IPKernelApp
9 from IPython.kernel.zmq.kernelapp import IPKernelApp
10 10
11 11 #-----------------------------------------------------------------------------
12 12 # Functions and classes
13 13 #-----------------------------------------------------------------------------
14 14 def pylab_kernel(gui):
15 15 """Launch and return an IPython kernel with pylab support for the desired gui
16 16 """
17 17 kernel = IPKernelApp.instance()
18 18 kernel.initialize(['python', '--pylab=%s' % gui,
19 19 #'--log-level=10'
20 20 ])
21 21 return kernel
22 22
23 23
24 24 class InternalIPKernel(object):
25 25
26 26 def init_ipkernel(self, backend):
27 27 # Start IPython kernel with GUI event loop and pylab support
28 28 self.ipkernel = pylab_kernel(backend)
29 29 # To create and track active qt consoles
30 30 self.consoles = []
31 31
32 32 # This application will also act on the shell user namespace
33 33 self.namespace = self.ipkernel.shell.user_ns
34 34 # Keys present at startup so we don't print the entire pylab/numpy
35 35 # namespace when the user clicks the 'namespace' button
36 36 self._init_keys = set(self.namespace.keys())
37 37
38 38 # Example: a variable that will be seen by the user in the shell, and
39 39 # that the GUI modifies (the 'Counter++' button increments it):
40 40 self.namespace['app_counter'] = 0
41 41 #self.namespace['ipkernel'] = self.ipkernel # dbg
42 42
43 43 def print_namespace(self, evt=None):
44 44 print("\n***Variables in User namespace***")
45 45 for k, v in self.namespace.iteritems():
46 46 if k not in self._init_keys and not k.startswith('_'):
47 47 print('%s -> %r' % (k, v))
48 48 sys.stdout.flush()
49 49
50 50 def new_qt_console(self, evt=None):
51 51 """start a new qtconsole connected to our kernel"""
52 52 return connect_qtconsole(self.ipkernel.connection_file, profile=self.ipkernel.profile)
53 53
54 54 def count(self, evt=None):
55 55 self.namespace['app_counter'] += 1
56 56
57 57 def cleanup_consoles(self, evt=None):
58 58 for c in self.consoles:
59 59 c.kill()
General Comments 0
You need to be logged in to leave comments. Login now