##// END OF EJS Templates
* Tab completion now uses the correct cursor position....
* Tab completion now uses the correct cursor position. * Added trailing newline to pyerr traceback. * Made 'colors lightbg' hack appear less funky to the user.

File last commit:

r2841:58941baa
r2841:58941baa
Show More
ipythonqt.py
86 lines | 3.2 KiB | text/x-python | PythonLexer
epatters
Created a proper IPython script from the console frontend demo.
r2801 #!/usr/bin/env python
""" A minimal application using the Qt console-style IPython frontend.
epatters
* The SVG payload matplotlib backend now works....
r2758 """
# Systemm library imports
from PyQt4 import QtCore, QtGui
# Local imports
from IPython.external.argparse import ArgumentParser
epatters
Created a proper IPython script from the console frontend demo.
r2801 from IPython.frontend.qt.console.frontend_widget import FrontendWidget
from IPython.frontend.qt.console.ipython_widget import IPythonWidget
from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
epatters
* The SVG payload matplotlib backend now works....
r2758 from IPython.frontend.qt.kernelmanager import QtKernelManager
epatters
Added arguments to the Qt console frontend script for connecting to an existing kernel and for specifying an IP and specific ports.
r2823 # Constants
LOCALHOST = '127.0.0.1'
epatters
* The SVG payload matplotlib backend now works....
r2758
def main():
epatters
Created a proper IPython script from the console frontend demo.
r2801 """ Entry point for application.
epatters
* The SVG payload matplotlib backend now works....
r2758 """
# Parse command line arguments.
parser = ArgumentParser()
epatters
Added arguments to the Qt console frontend script for connecting to an existing kernel and for specifying an IP and specific ports.
r2823 parser.add_argument('-e', '--existing', action='store_true',
help='connect to an existing kernel')
parser.add_argument('--ip', type=str, default=LOCALHOST,
help='set the kernel\'s IP address [default localhost]')
parser.add_argument('--xreq', type=int, metavar='PORT', default=0,
help='set the XREQ channel port [default random]')
parser.add_argument('--sub', type=int, metavar='PORT', default=0,
help='set the SUB channel port [default random]')
parser.add_argument('--rep', type=int, metavar='PORT', default=0,
help='set the REP channel port [default random]')
epatters
* Restored functionality after major merge....
r2778 group = parser.add_mutually_exclusive_group()
group.add_argument('--pure', action='store_true', help = \
'use a pure Python kernel instead of an IPython kernel')
group.add_argument('--pylab', action='store_true',
help='use a kernel with PyLab enabled')
epatters
* The SVG payload matplotlib backend now works....
r2758 parser.add_argument('--rich', action='store_true',
epatters
* Restored functionality after major merge....
r2778 help='use a rich text frontend')
epatters
Added arguments to the Qt console frontend script for connecting to an existing kernel and for specifying an IP and specific ports.
r2823 args = parser.parse_args()
epatters
* The SVG payload matplotlib backend now works....
r2758
# Don't let Qt or ZMQ swallow KeyboardInterupts.
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
# Create a KernelManager and start a kernel.
epatters
Added arguments to the Qt console frontend script for connecting to an existing kernel and for specifying an IP and specific ports.
r2823 kernel_manager = QtKernelManager(xreq_address=(args.ip, args.xreq),
sub_address=(args.ip, args.sub),
rep_address=(args.ip, args.rep))
if args.ip == LOCALHOST and not args.existing:
if args.pure:
kernel_manager.start_kernel(ipython=False)
elif args.pylab:
if args.rich:
kernel_manager.start_kernel(pylab='payload-svg')
else:
kernel_manager.start_kernel(pylab='qt4')
epatters
* The SVG payload matplotlib backend now works....
r2758 else:
epatters
Added arguments to the Qt console frontend script for connecting to an existing kernel and for specifying an IP and specific ports.
r2823 kernel_manager.start_kernel()
epatters
* The SVG payload matplotlib backend now works....
r2758 kernel_manager.start_channels()
epatters
* Tab completion now uses the correct cursor position....
r2841 # Create the widget.
epatters
* The SVG payload matplotlib backend now works....
r2758 app = QtGui.QApplication([])
epatters
Added arguments to the Qt console frontend script for connecting to an existing kernel and for specifying an IP and specific ports.
r2823 if args.pure:
kind = 'rich' if args.rich else 'plain'
epatters
* Restored functionality after major merge....
r2778 widget = FrontendWidget(kind=kind)
epatters
Added arguments to the Qt console frontend script for connecting to an existing kernel and for specifying an IP and specific ports.
r2823 elif args.rich:
widget = RichIPythonWidget()
epatters
* The SVG payload matplotlib backend now works....
r2758 else:
epatters
Added arguments to the Qt console frontend script for connecting to an existing kernel and for specifying an IP and specific ports.
r2823 widget = IPythonWidget()
epatters
* The SVG payload matplotlib backend now works....
r2758 widget.kernel_manager = kernel_manager
epatters
Added arguments to the Qt console frontend script for connecting to an existing kernel and for specifying an IP and specific ports.
r2823 widget.setWindowTitle('Python' if args.pure else 'IPython')
epatters
* The SVG payload matplotlib backend now works....
r2758 widget.show()
epatters
* Tab completion now uses the correct cursor position....
r2841
# FIXME: This is a hack: set colors to lightbg by default in qt terminal
# unconditionally, regardless of user settings in config files.
widget.execute("%colors lightbg", hidden=True)
# Start the application main loop.
epatters
* The SVG payload matplotlib backend now works....
r2758 app.exec_()
if __name__ == '__main__':
main()