本文整理汇总了Python中IPython.qt.inprocess.QtInProcessKernelManager.client方法的典型用法代码示例。如果您正苦于以下问题:Python QtInProcessKernelManager.client方法的具体用法?Python QtInProcessKernelManager.client怎么用?Python QtInProcessKernelManager.client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.qt.inprocess.QtInProcessKernelManager
的用法示例。
在下文中一共展示了QtInProcessKernelManager.client方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def main():
# Print the ID of the main process
print_process_id()
app = guisupport.get_app_qt4()
# Create an in-process kernel
# >>> print_process_id()
# will print the same process ID as the main process
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
kernel = kernel_manager.kernel
kernel.gui = 'qt4'
kernel.shell.push({'foo': 43, 'print_process_id': print_process_id})
kernel_client = kernel_manager.client()
kernel_client.start_channels()
def stop():
kernel_client.stop_channels()
kernel_manager.shutdown_kernel()
app.exit()
control = RichIPythonWidget()
control.kernel_manager = kernel_manager
control.kernel_client = kernel_client
control.exit_requested.connect(stop)
control.show()
guisupport.start_event_loop_qt4(app)
示例2: __init__
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def __init__(self, main_window):
"""
desc:
Constructor.
arguments:
main_window: The main window object.
"""
super(ipython_console, self).__init__(main_window)
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
self.kernel = kernel_manager.kernel
self.kernel.gui = 'qt4'
self.kernel.shell.banner1 = ''
kernel_client = kernel_manager.client()
kernel_client.start_channels()
self.control = RichIPythonWidget()
self.control.banner = self.banner()
self.control.kernel_manager = kernel_manager
self.control.kernel_client = kernel_client
self.verticalLayout = QtGui.QVBoxLayout(self)
self.verticalLayout.setContentsMargins(0,0,0,0)
self.setLayout(self.verticalLayout)
self.verticalLayout.addWidget(self.control)
示例3: __init__
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def __init__(self, *args, **kw):
super(MantidIPythonWidget, self).__init__(*args, **kw)
# Create an in-process kernel
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
kernel = kernel_manager.kernel
kernel.gui = 'qt4'
# Figure out the full path to the mantidplotrc.py file and then %run it
from os import path
mantidplotpath = path.split(path.dirname(__file__))[0] # It's the directory above this one
mantidplotrc = path.join(mantidplotpath, 'mantidplotrc.py')
shell = kernel.shell
shell.run_line_magic('run',mantidplotrc)
# These 3 lines replace the run_code method of IPython's InteractiveShell class (of which the
# shell variable is a derived instance) with our method defined above. The original method
# is renamed so that we can call it from within the our_run_code method.
f = shell.run_code
shell.run_code = types.MethodType(our_run_code, shell)
shell.ipython_run_code = f
kernel_client = kernel_manager.client()
kernel_client.start_channels()
self.kernel_manager = kernel_manager
self.kernel_client = kernel_client
示例4: show_ipython_console
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def show_ipython_console():
# from https://github.com/ipython/ipython/blob/1.x/examples/inprocess/embedded_qtconsole.py
# this might be able to be a dockable panel at some point in the future.
# it should also only allow one window open at a time - I think it steals stdout at start
# and opening a new window stops output working on the old one!
app = guisupport.get_app_qt4()
# Create an in-process kernel
# >>> print_process_id()
# will print the same process ID as the main process
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
kernel = kernel_manager.kernel
kernel.gui = 'qt4'
kernel_client = kernel_manager.client()
kernel_client.start_channels()
def stop():
kernel_client.stop_channels()
kernel_manager.shutdown_kernel()
app.exit()
control = RichIPythonWidget()
control.kernel_manager = kernel_manager
control.kernel_client = kernel_client
control.exit_requested.connect(stop)
control.show()
guisupport.start_event_loop_qt4(app)
示例5: __init__
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def __init__(self):
QMainWindow.__init__(self)
self.hsplit = QSplitter()
self.setCentralWidget(self.hsplit)
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
self.kernel = kernel_manager.kernel
self.kernel.gui = 'qt'
self.control = RichIPythonWidget(gui_completion="droplist")
self.kernel.shell.push({'snipdom': self})
kernel_client = kernel_manager.client()
kernel_client.start_channels()
self.control.kernel_manager = kernel_manager
self.control.kernel_client = kernel_client
self.vsplit = QSplitter()
self.vsplit.setOrientation(Qt.Vertical)
self.vsplit.addWidget(self.control)
self.hsplit.addWidget(self.vsplit)
self.sendButton = QPushButton("send")
#self.sendButton.clicked.connect(self.sendcode)
self.vsplit.addWidget(self.sendButton)
self.bridge = Js2Py()
self.bridge.sent.connect(self.codeFromJs)
示例6: initialize
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def initialize(self):
# Init your plugin
self.misc_s = self.locator.get_service('misc')
explorer_container = self.locator.get_service('explorer')
tree = explorer_container.get_tree_projects()
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
kernel = kernel_manager.kernel
kernel.gui = 'qt4'
kernel_client = kernel_manager.client()
kernel_client.start_channels()
def stop():
kernel_client.stop_channels()
kernel_manager.shutdown_kernel()
self.ipython_console = RichIPythonWidget()
self.ipython_console.kernel_manager = kernel_manager
self.ipython_console.kernel_client = kernel_client
self.ipython_console.exit_requested.connect(stop)
self.ipython_console.show()
self.misc_s.add_widget(self.ipython_console, IMAGES["console"],
"IPython console")
addp = SIGNAL("addProjectToConsole(QString)")
delp = SIGNAL("removeProjectFromConsole(QString)")
self.connect(tree, addp, self._add_project)
self.connect(tree, delp, self._del_project)
示例7: in_process_console
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def in_process_console(console_class=RichIPythonWidget, **kwargs):
"""Create a console widget, connected to an in-process Kernel
This only works on IPython v 0.13 and above
Parameters
----------
console_class : The class of the console widget to create
kwargs : Extra variables to put into the namespace
"""
km = QtInProcessKernelManager()
km.start_kernel()
kernel = km.kernel
kernel.gui = 'qt4'
client = km.client()
client.start_channels()
control = console_class()
control.kernel_manager = km
control.kernel_client = client
control.shell = kernel.shell
control.shell.user_ns.update(**kwargs)
return control
示例8: __init__
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def __init__(self, parent):
from logging import getLogger, CRITICAL
logger=getLogger()
silenced=None
for handler in logger.handlers:
if handler.__class__.__name__=='QtHandler':
silenced=handler
old_level=silenced.level
silenced.setLevel(CRITICAL+1)
break
RichIPythonWidget.__init__(self)
self._parent=parent
self.buffer_size=10000 # increase buffer size to show longer outputs
self.set_default_style(colors='linux')
if IPython.__version__<'1.0':
kernelapp=IPythonLocalKernelApp.instance()
kernelapp.initialize()
self.connect_kernel(connection_file=kernelapp.get_connection_file())
else:
kernel_manager=QtInProcessKernelManager(config=self.config, gui='qt4')
kernel_manager.start_kernel()
self.kernel_manager=kernel_manager
self.kernel_client=kernel_manager.client()
self.kernel_client.start_channels()
ip=get_ipython()
# console process exceptions (IPython controlled)
ip.set_custom_exc((Exception,), ip_excepthook_overwrite)
self.namespace=ip.user_ns
self.namespace['IP']=self
self.namespace['app']=QtGui.QApplication.instance()
self.namespace['gui']=parent
self.namespace['plot']=self._plot
if silenced:
silenced.setLevel(old_level)
示例9: main
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def main():
"""Start kernel manager and client, create window, run app event loop"""
app = guisupport.get_app_qt4()
if INPROCESS:
from IPython.qt.inprocess import QtInProcessKernelManager
km = QtInProcessKernelManager()
else:
from IPython.qt.manager import QtKernelManager
km = QtKernelManager()
km.start_kernel()
km.kernel.gui = 'qt4'
kc = km.client()
kc.start_channels()
widget = RichIPythonWidget()
widget.kernel_manager = km
widget.kernel_client = kc
if CLEANSHUTDOWN: # slow exit on CTRL+D
def stop():
kc.stop_channels()
km.shutdown_kernel()
app.exit()
widget.exit_requested.connect(stop)
else: # fast exit on CTRL+D
widget.exit_requested.connect(app.quit)
widget.show()
guisupport.start_event_loop_qt4(app)
示例10: IPythonView
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
class IPythonView(QtGui.QWidget):
def __init__(self, parent=None, getfocus=None):
super(IPythonView, self).__init__(parent)
# Create an in-process kernel
self.kernel_manager = QtInProcessKernelManager()
self.kernel_manager.start_kernel()
self.kernel = self.kernel_manager.kernel
self.kernel.gui = 'qt4'
self.shell = self.kernel.shell
self.kernel_client = self.kernel_manager.client()
self.kernel_client.start_channels()
self.control = RichIPythonWidget()
self.control.set_default_style(colors='linux')
self.control.kernel_manager = self.kernel_manager
self.control.kernel_client = self.kernel_client
self.control.exit_requested.connect(self.stop)
# Enable Pylab mode.
self.shell.enable_pylab()
self.shell.automagic = True
# Add some variables in the namespace.
self.push(galry=galry)
box = QtGui.QVBoxLayout()
box.addWidget(self.control)
box.setContentsMargins(0, 0, 0, 0)
box.setSpacing(0)
self.setLayout(box)
def stop(self, *args):
self.kernel_client.stop_channels()
self.kernel_manager.shutdown_kernel()
# Public methods.
# ---------------
def set_data(self, **kwargs):
self.push(**kwargs)
def push(self, **kwargs):
"""Inject variables in the interactive namespace."""
self.shell.push(kwargs)
def run_file(self, file):
"""Execute a Python file in the interactive namespace."""
self.shell.safe_execfile(file, self.shell.user_global_ns)
def run_cell(self, *args, **kwargs):
"""Execute a cell."""
self.shell.run_cell(*args, **kwargs)
示例11: __init__
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def __init__(self, interpreter=None, message="", log="", parent=None):
"""
:param interpreter : InteractiveInterpreter in which
the code will be executed
:param message: welcome message string
:param parent: specifies the parent widget.
If no parent widget has been specified, it is possible to
exit the interpreter by Ctrl-D.
"""
if interpreter is None:
from openalea.core.service.ipython import interpreter
interpreter = interpreter()
# Set interpreter
self.interpreter = interpreter
self.interpreter.widget = self
# Multiple Stream Redirection
GraphicalStreamRedirection.__init__(self)
# Compatibility with visualea
self.runsource = self.interpreter.run_cell
self.runcode = self.interpreter.runcode
self.loadcode = self.interpreter.loadcode
# Write welcome message
self.write(message)
# Set kernel manager
try:
from IPython.qt.inprocess import QtInProcessKernelManager
except ImportError:
import warnings
message = "You are using a deprecated version of IPython (please update)."
warnings.warn(message)
# DEPRECATED !
from IPython.frontend.qt.inprocess_kernelmanager import QtInProcessKernelManager
km = QtInProcessKernelManager(kernel=self.interpreter)
km.start_channels()
self.interpreter.frontends.append(km)
self.kernel_manager = km
else:
km = QtInProcessKernelManager()
km.kernel = self.interpreter
km.kernel.gui = "qt4"
kernel_client = km.client()
kernel_client.start_channels()
self.kernel_manager = km
self.kernel_client = kernel_client
示例12: EmbedIPython
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
class EmbedIPython(RichIPythonWidget):
def __init__(self, **kwarg):
super(RichIPythonWidget, self).__init__()
self.kernel_manager = QtInProcessKernelManager()
self.kernel_manager.start_kernel()
self.kernel = self.kernel_manager.kernel
self.kernel.gui = "qt4"
self.kernel.shell.push(kwarg)
self.kernel_client = self.kernel_manager.client()
self.kernel_client.start_channels()
示例13: _setup_kernel
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def _setup_kernel(self):
""" Setup the kernel for the widget.
"""
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
kernel_client = kernel_manager.client()
kernel_client.start_channels()
ipy_widget = self.ipy_widget
ipy_widget.kernel_manager = kernel_manager
ipy_widget.kernel_client = kernel_client
示例14: __init__
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def __init__( self, parent ):
super(self.__class__, self).__init__(parent)
# Create an in-process kernel
kernel = InProcessKernel(gui='qt4')
kernel_manager = QtInProcessKernelManager(kernel=kernel)
kernel_manager.start_kernel()
kernel_client = kernel_manager.client()
kernel_client.start_channels()
self.kernel_manager = kernel_manager
self.kernel_client = kernel_client
self.kernel = kernel
self.exit_requested.connect(self._stop)
self.show()
示例15: _load_ipython
# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import client [as 别名]
def _load_ipython(self):
# Create an in-process kernel
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
kernel_manager.kernel.gui = "qt4"
kernel_manager.kernel.shell.enable_pylab(gui="inline")
kernel_client = kernel_manager.client()
kernel_client.start_channels()
control = RichIPythonWidget()
self.ipythonDockWidget.setWidget(control)
control.kernel_manager = kernel_manager
control.kernel_client = kernel_client
control.exit_requested.connect(kernel_client.stop_channels)
control.exit_requested.connect(kernel_manager.shutdown_kernel)
class IPythonNamespaceUpdater(QtCore.QObject):
shell = kernel_manager.kernel.shell
def eventFilter(self, target, e):
if e.type() == QtCore.QEvent.Enter:
self.shell.push(globals())
return False
control.installEventFilter(IPythonNamespaceUpdater(self))
class Debug(object):
def __init__(self, shell):
self.shell = shell
def __call__(self):
import inspect
frame = inspect.currentframe()
try:
temp = frame.f_back.f_globals
temp.update(frame.f_back.f_locals)
finally:
del frame
self.shell.run_line_magic("reset", "-f -s")
self.shell.push(temp)
# now monkeypatch hexrd.debug to use the qt console:
hexrd.debug = Debug(kernel_manager.kernel.shell)