##// END OF EJS Templates
Added arguments to the Qt console frontend script for connecting to an existing kernel and for specifying an IP and specific ports.
epatters -
Show More
@@ -13,12 +13,25 b' from IPython.frontend.qt.console.ipython_widget import IPythonWidget'
13 13 from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
14 14 from IPython.frontend.qt.kernelmanager import QtKernelManager
15 15
16 # Constants
17 LOCALHOST = '127.0.0.1'
18
16 19
17 20 def main():
18 21 """ Entry point for application.
19 22 """
20 23 # Parse command line arguments.
21 24 parser = ArgumentParser()
25 parser.add_argument('-e', '--existing', action='store_true',
26 help='connect to an existing kernel')
27 parser.add_argument('--ip', type=str, default=LOCALHOST,
28 help='set the kernel\'s IP address [default localhost]')
29 parser.add_argument('--xreq', type=int, metavar='PORT', default=0,
30 help='set the XREQ channel port [default random]')
31 parser.add_argument('--sub', type=int, metavar='PORT', default=0,
32 help='set the SUB channel port [default random]')
33 parser.add_argument('--rep', type=int, metavar='PORT', default=0,
34 help='set the REP channel port [default random]')
22 35 group = parser.add_mutually_exclusive_group()
23 36 group.add_argument('--pure', action='store_true', help = \
24 37 'use a pure Python kernel instead of an IPython kernel')
@@ -26,18 +39,21 b' def main():'
26 39 help='use a kernel with PyLab enabled')
27 40 parser.add_argument('--rich', action='store_true',
28 41 help='use a rich text frontend')
29 namespace = parser.parse_args()
42 args = parser.parse_args()
30 43
31 44 # Don't let Qt or ZMQ swallow KeyboardInterupts.
32 45 import signal
33 46 signal.signal(signal.SIGINT, signal.SIG_DFL)
34 47
35 48 # Create a KernelManager and start a kernel.
36 kernel_manager = QtKernelManager()
37 if namespace.pure:
49 kernel_manager = QtKernelManager(xreq_address=(args.ip, args.xreq),
50 sub_address=(args.ip, args.sub),
51 rep_address=(args.ip, args.rep))
52 if args.ip == LOCALHOST and not args.existing:
53 if args.pure:
38 54 kernel_manager.start_kernel(ipython=False)
39 elif namespace.pylab:
40 if namespace.rich:
55 elif args.pylab:
56 if args.rich:
41 57 kernel_manager.start_kernel(pylab='payload-svg')
42 58 else:
43 59 kernel_manager.start_kernel(pylab='qt4')
@@ -47,16 +63,15 b' def main():'
47 63
48 64 # Launch the application.
49 65 app = QtGui.QApplication([])
50 if namespace.pure:
51 kind = 'rich' if namespace.rich else 'plain'
66 if args.pure:
67 kind = 'rich' if args.rich else 'plain'
52 68 widget = FrontendWidget(kind=kind)
53 else:
54 if namespace.rich:
69 elif args.rich:
55 70 widget = RichIPythonWidget()
56 71 else:
57 72 widget = IPythonWidget()
58 73 widget.kernel_manager = kernel_manager
59 widget.setWindowTitle('Python' if namespace.pure else 'IPython')
74 widget.setWindowTitle('Python' if args.pure else 'IPython')
60 75 widget.show()
61 76 app.exec_()
62 77
General Comments 0
You need to be logged in to leave comments. Login now