当前位置: 首页>>代码示例>>Python>>正文


Python QtInProcessKernelManager.start_kernel方法代码示例

本文整理汇总了Python中IPython.qt.inprocess.QtInProcessKernelManager.start_kernel方法的典型用法代码示例。如果您正苦于以下问题:Python QtInProcessKernelManager.start_kernel方法的具体用法?Python QtInProcessKernelManager.start_kernel怎么用?Python QtInProcessKernelManager.start_kernel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPython.qt.inprocess.QtInProcessKernelManager的用法示例。


在下文中一共展示了QtInProcessKernelManager.start_kernel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show_ipython_console

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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)
开发者ID:Bejoscha,项目名称:Dimpy,代码行数:32,代码来源:open_ipython_window.py

示例2: __init__

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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)
开发者ID:JdenHartog,项目名称:OpenSesame,代码行数:28,代码来源:_ipython_console.py

示例3: main

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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)
开发者ID:AJRenold,项目名称:ipython,代码行数:32,代码来源:embedded_qtconsole.py

示例4: __init__

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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)
开发者ID:marcellmars,项目名称:orangecase,代码行数:36,代码来源:isnipdom.py

示例5: initialize

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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)
开发者ID:Hassenky,项目名称:ninja_ipython_console,代码行数:34,代码来源:ipythonconsole_1_1_x_compat.py

示例6: __init__

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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)
开发者ID:aglavic,项目名称:quicknxs,代码行数:36,代码来源:ipython_widget.py

示例7: in_process_console

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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
开发者ID:Spencerx,项目名称:glue,代码行数:28,代码来源:terminal.py

示例8: __init__

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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
开发者ID:jkrueger1,项目名称:mantid,代码行数:30,代码来源:mantid_ipython_widget.py

示例9: main

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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)
开发者ID:guangxingli,项目名称:neuropy,代码行数:30,代码来源:qt_ip_test.py

示例10: IPythonView

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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)
开发者ID:Jackieee,项目名称:klustaviewa,代码行数:59,代码来源:ipythonview.py

示例11: EmbedIPython

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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()
开发者ID:floydgyf,项目名称:quantdigger,代码行数:12,代码来源:pyquant.py

示例12: _setup_kernel

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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
开发者ID:MatthieuDartiailh,项目名称:enaml,代码行数:13,代码来源:qt_ipython_console.py

示例13: __init__

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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()
开发者ID:bthcode,项目名称:cmake_scipy_ctypes_example,代码行数:19,代码来源:qt_utils.py

示例14: _load_ipython

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [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)
开发者ID:beamteamco,项目名称:hexrd,代码行数:47,代码来源:main.py

示例15: terminal_widget

# 需要导入模块: from IPython.qt.inprocess import QtInProcessKernelManager [as 别名]
# 或者: from IPython.qt.inprocess.QtInProcessKernelManager import start_kernel [as 别名]
def terminal_widget(**kwargs):

    # 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(kwargs)

    kernel_client = kernel_manager.client()
    kernel_client.start_channels()

    control = RichIPythonWidget()
    control.kernel_manager = kernel_manager
    control.kernel_client = kernel_client
    return control
开发者ID:101baja202,项目名称:mcedit2,代码行数:20,代码来源:ipython_widget.py


注:本文中的IPython.qt.inprocess.QtInProcessKernelManager.start_kernel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。