##// END OF EJS Templates
REFACTOR: Terminology change: 'embedded' -> 'in-process'.
REFACTOR: Terminology change: 'embedded' -> 'in-process'.

File last commit:

r8471:bd40426d
r8471:bd40426d
Show More
inprocess_qtconsole.py
41 lines | 1.3 KiB | text/x-python | PythonLexer
/ docs / examples / frontend / inprocess_qtconsole.py
epatters
REFACTOR: Terminology change: 'embedded' -> 'in-process'.
r8471 from IPython.inprocess.ipkernel import InProcessKernel
epatters
DOC: Add an example showing off the embedded Qt console.
r8457 from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
epatters
REFACTOR: Terminology change: 'embedded' -> 'in-process'.
r8471 from IPython.frontend.qt.inprocess_kernelmanager import QtInProcessKernelManager
epatters
DOC: Add an example showing off the embedded Qt console.
r8457 from IPython.lib import guisupport
def main():
app = guisupport.get_app_qt4()
# Create a kernel and populate the namespace.
epatters
REFACTOR: Terminology change: 'embedded' -> 'in-process'.
r8471 kernel = InProcessKernel()
epatters
DOC: Add an example showing off the embedded Qt console.
r8457 kernel.shell.push({'x': 0, 'y': 1, 'z': 2})
# Create a kernel manager for the frontend and register it with the kernel.
epatters
REFACTOR: Terminology change: 'embedded' -> 'in-process'.
r8471 km = QtInProcessKernelManager(kernel=kernel)
epatters
DOC: Add an example showing off the embedded Qt console.
r8457 km.start_channels()
kernel.frontends.append(km)
# Create the Qt console frontend.
control = RichIPythonWidget()
control.exit_requested.connect(app.quit)
control.kernel_manager = km
control.show()
# Execute some code directly. Note where the output appears.
kernel.shell.run_cell('print "x=%r, y=%r, z=%r" % (x,y,z)')
# Execute some code through the frontend (once the event loop is
# running). Again, note where the output appears.
do_later(control.execute, '%who')
guisupport.start_event_loop_qt4(app)
def do_later(func, *args, **kwds):
from IPython.external.qt import QtCore
QtCore.QTimer.singleShot(0, lambda: func(*args, **kwds))
if __name__ == '__main__':
main()