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


Python inprocess.QtInProcessKernelManager类代码示例

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


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

示例1: __init__

    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,代码行数:28,代码来源:mantid_ipython_widget.py

示例2: main

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,代码行数:30,代码来源:embedded_qtconsole.py

示例3: show_ipython_console

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,代码行数:30,代码来源:open_ipython_window.py

示例4: __init__

    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,代码行数:34,代码来源:isnipdom.py

示例5: initialize

    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,代码行数:32,代码来源:ipythonconsole_1_1_x_compat.py

示例6: __init__

	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,代码行数:26,代码来源:_ipython_console.py

示例7: in_process_console

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,代码行数:26,代码来源:terminal.py

示例8: __init__

 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,代码行数:34,代码来源:ipython_widget.py

示例9: main

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,代码行数:28,代码来源:qt_ip_test.py

示例10: IPythonView

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,代码行数:57,代码来源:ipythonview.py

示例11: EmbedIPython

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,代码行数:10,代码来源:pyquant.py

示例12: _setup_kernel

    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,代码行数:11,代码来源:qt_ipython_console.py

示例13: __init__

    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)
开发者ID:Jackieee,项目名称:klustaviewa,代码行数:34,代码来源:ipythonview.py

示例14: main

 def main(self):
     # Print the ID of the main process
     #self.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
     self.kernel_manager = QtInProcessKernelManager()
     self.kernel_manager.start_kernel()
     self.kernel = self.kernel_manager.kernel
     self.kernel.gui = 'qt4'
     self.kernel.shell.push(self.common.__dict__)
     self.kernel_client = self.kernel_manager.client()
     self.kernel_client.start_channels()
     
     def stop():
         self.kernel_client.stop_channels()
         self.kernel_manager.shutdown_kernel()
         #app.exit()
 
     self.control = RichIPythonWidget(banner = self.banner)
     self.control.kernel_manager = self.kernel_manager
     self.control.kernel_client = self.kernel_client
     self.control.exit_requested.connect(stop)
     
     #start widget with certain inputs:
     #import pylab, which includes all numpy; import pandas as pd
     #second argument is whether the execution is hidden e.g. whether a line is used
     #I have turned on hide.
     
     self.control._execute('import pylab as pl; import pandas as pd',True)
开发者ID:eegroopm,项目名称:pyLATTICE,代码行数:33,代码来源:IPythonConsole.py

示例15: __init__

    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,代码行数:17,代码来源:qt_utils.py


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