##// 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 from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
13 from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
14 from IPython.frontend.qt.kernelmanager import QtKernelManager
14 from IPython.frontend.qt.kernelmanager import QtKernelManager
15
15
16 # Constants
17 LOCALHOST = '127.0.0.1'
18
16
19
17 def main():
20 def main():
18 """ Entry point for application.
21 """ Entry point for application.
19 """
22 """
20 # Parse command line arguments.
23 # Parse command line arguments.
21 parser = ArgumentParser()
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 group = parser.add_mutually_exclusive_group()
35 group = parser.add_mutually_exclusive_group()
23 group.add_argument('--pure', action='store_true', help = \
36 group.add_argument('--pure', action='store_true', help = \
24 'use a pure Python kernel instead of an IPython kernel')
37 'use a pure Python kernel instead of an IPython kernel')
@@ -26,18 +39,21 b' def main():'
26 help='use a kernel with PyLab enabled')
39 help='use a kernel with PyLab enabled')
27 parser.add_argument('--rich', action='store_true',
40 parser.add_argument('--rich', action='store_true',
28 help='use a rich text frontend')
41 help='use a rich text frontend')
29 namespace = parser.parse_args()
42 args = parser.parse_args()
30
43
31 # Don't let Qt or ZMQ swallow KeyboardInterupts.
44 # Don't let Qt or ZMQ swallow KeyboardInterupts.
32 import signal
45 import signal
33 signal.signal(signal.SIGINT, signal.SIG_DFL)
46 signal.signal(signal.SIGINT, signal.SIG_DFL)
34
47
35 # Create a KernelManager and start a kernel.
48 # Create a KernelManager and start a kernel.
36 kernel_manager = QtKernelManager()
49 kernel_manager = QtKernelManager(xreq_address=(args.ip, args.xreq),
37 if namespace.pure:
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 kernel_manager.start_kernel(ipython=False)
54 kernel_manager.start_kernel(ipython=False)
39 elif namespace.pylab:
55 elif args.pylab:
40 if namespace.rich:
56 if args.rich:
41 kernel_manager.start_kernel(pylab='payload-svg')
57 kernel_manager.start_kernel(pylab='payload-svg')
42 else:
58 else:
43 kernel_manager.start_kernel(pylab='qt4')
59 kernel_manager.start_kernel(pylab='qt4')
@@ -47,16 +63,15 b' def main():'
47
63
48 # Launch the application.
64 # Launch the application.
49 app = QtGui.QApplication([])
65 app = QtGui.QApplication([])
50 if namespace.pure:
66 if args.pure:
51 kind = 'rich' if namespace.rich else 'plain'
67 kind = 'rich' if args.rich else 'plain'
52 widget = FrontendWidget(kind=kind)
68 widget = FrontendWidget(kind=kind)
53 else:
69 elif args.rich:
54 if namespace.rich:
55 widget = RichIPythonWidget()
70 widget = RichIPythonWidget()
56 else:
71 else:
57 widget = IPythonWidget()
72 widget = IPythonWidget()
58 widget.kernel_manager = kernel_manager
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 widget.show()
75 widget.show()
61 app.exec_()
76 app.exec_()
62
77
General Comments 0
You need to be logged in to leave comments. Login now