##// 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 18 # Stdlib
19 19 import inspect
20 20 import os
21 import sys
22 from subprocess import Popen, PIPE
21 23
22 24 # Our own
23 25 from IPython.core.interactiveshell import (
@@ -442,7 +444,7 b' class ZMQInteractiveShell(InteractiveShell):'
442 444 """
443 445 from IPython.zmq.kernelapp import KernelApp
444 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 448 return
447 449 app = KernelApp.instance()
448 450 try:
@@ -462,6 +464,27 b' class ZMQInteractiveShell(InteractiveShell):'
462 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 488 def set_next_input(self, text):
466 489 """Send the specified text to the frontend to be presented at the next
467 490 input cell."""
General Comments 0
You need to be logged in to leave comments. Login now