##// END OF EJS Templates
update internal_ipkernel example to use connection files
MinRK -
Show More
@@ -5,6 +5,7
5 5 import subprocess
6 6 import sys
7 7
8 from IPython.lib.kernel import connect_qtconsole
8 9 from IPython.zmq.ipkernel import IPKernelApp
9 10
10 11 #-----------------------------------------------------------------------------
@@ -13,27 +14,19 from IPython.zmq.ipkernel import IPKernelApp
13 14 def pylab_kernel(gui):
14 15 """Launch and return an IPython kernel with pylab support for the desired gui
15 16 """
16 kernel = IPKernelApp()
17 kernel = IPKernelApp.instance()
17 18 kernel.initialize(['python', '--pylab=%s' % gui,
18 19 #'--log-level=10'
19 20 ])
20 21 return kernel
21 22
22 23
23 def qtconsole_cmd(kernel):
24 """Compute the command to connect a qt console to an already running kernel
25 """
26 ports = ['--%s=%d' % (name, port) for name, port in kernel.ports.items()]
27 return ['ipython', 'qtconsole', '--existing'] + ports
28
29
30 24 class InternalIPKernel(object):
31 25
32 26 def init_ipkernel(self, backend):
33 27 # Start IPython kernel with GUI event loop and pylab support
34 28 self.ipkernel = pylab_kernel(backend)
35 29 # To create and track active qt consoles
36 self._qtconsole_cmd = qtconsole_cmd(self.ipkernel)
37 30 self.consoles = []
38 31
39 32 # This application will also act on the shell user namespace
@@ -55,7 +48,8 class InternalIPKernel(object):
55 48 sys.stdout.flush()
56 49
57 50 def new_qt_console(self, evt=None):
58 self.consoles.append(subprocess.Popen(self._qtconsole_cmd))
51 """start a new qtconsole connected to our kernel"""
52 return connect_qtconsole(self.ipkernel.connection_file, profile=self.ipkernel.profile)
59 53
60 54 def count(self, evt=None):
61 55 self.namespace['app_counter'] += 1
General Comments 0
You need to be logged in to leave comments. Login now