##// END OF EJS Templates
add %qtconsole magic for conveniently launching second console
MinRK -
Show More
@@ -18,6 +18,8 b' from __future__ import print_function'
18 # Stdlib
18 # Stdlib
19 import inspect
19 import inspect
20 import os
20 import os
21 import sys
22 from subprocess import Popen, PIPE
21
23
22 # Our own
24 # Our own
23 from IPython.core.interactiveshell import (
25 from IPython.core.interactiveshell import (
@@ -442,7 +444,7 b' class ZMQInteractiveShell(InteractiveShell):'
442 """
444 """
443 from IPython.zmq.kernelapp import KernelApp
445 from IPython.zmq.kernelapp import KernelApp
444 if not KernelApp.initialized():
446 if not KernelApp.initialized():
445 error("Not KernelApp is not initialized. I cannot find the connection info")
447 error("KernelApp is not initialized. I cannot find the connection info")
446 return
448 return
447 app = KernelApp.instance()
449 app = KernelApp.instance()
448 try:
450 try:
@@ -462,6 +464,27 b' class ZMQInteractiveShell(InteractiveShell):'
462 % os.path.basename((app.connection_file))
464 % os.path.basename((app.connection_file))
463 )
465 )
464
466
467 def magic_qtconsole(self, arg_s):
468 """Open a qtconsole connected to this kernel.
469
470 Useful for connecting a qtconsole to running notebooks, for better
471 debugging.
472 """
473 from IPython.zmq.kernelapp import KernelApp
474
475 if not KernelApp.initialized():
476 error("KernelApp is not initialized. %qtconsole magic must be run from a Kernel")
477 return
478 app = KernelApp.instance()
479
480 cmd = ';'.join([
481 "from IPython.frontend.qt.console import qtconsoleapp",
482 "qtconsoleapp.main()"
483 ])
484
485 return Popen([sys.executable, '-c', cmd, '--existing', app.connection_file],
486 stdout=PIPE,stderr=PIPE)
487
465 def set_next_input(self, text):
488 def set_next_input(self, text):
466 """Send the specified text to the frontend to be presented at the next
489 """Send the specified text to the frontend to be presented at the next
467 input cell."""
490 input cell."""
General Comments 0
You need to be logged in to leave comments. Login now