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


Python Application.initialized方法代码示例

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


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

示例1: pylab

# 需要导入模块: from traitlets.config.application import Application [as 别名]
# 或者: from traitlets.config.application.Application import initialized [as 别名]
    def pylab(self, line=""):
        """Load numpy and matplotlib to work interactively.

        This function lets you activate pylab (matplotlib, numpy and
        interactive support) at any point during an IPython session.
        
        %pylab makes the following imports::
        
            import numpy
            import matplotlib
            from matplotlib import pylab, mlab, pyplot
            np = numpy
            plt = pyplot
            
            from IPython.display import display
            from IPython.core.pylabtools import figsize, getfigs
            
            from pylab import *
            from numpy import *

        If you pass `--no-import-all`, the last two `*` imports will be excluded.
        
        See the %matplotlib magic for more details about activating matplotlib
        without affecting the interactive namespace.
        """
        args = magic_arguments.parse_argstring(self.pylab, line)
        if args.no_import_all is None:
            # get default from Application
            if Application.initialized():
                app = Application.instance()
                try:
                    import_all = app.pylab_import_all
                except AttributeError:
                    import_all = True
            else:
                # nothing specified, no classes - default True
                import_all = True
        else:
            # invert no-import flag
            import_all = not args.no_import_all

        gui, backend, clobbered = self.shell.enable_pylab(args.gui, import_all=import_all)
        self._show_matplotlib_backend(args.gui, backend)
        print("Populating the interactive namespace from numpy and matplotlib")
        if clobbered:
            warn(
                "pylab import has clobbered these variables: %s" % clobbered
                + "\n`%matplotlib` prevents importing * from pylab and numpy"
            )
开发者ID:GoestaO,项目名称:blog,代码行数:51,代码来源:pylab.py

示例2: enable_gui

# 需要导入模块: from traitlets.config.application import Application [as 别名]
# 或者: from traitlets.config.application.Application import initialized [as 别名]
def enable_gui(gui, kernel=None):
    """Enable integration with a given GUI"""
    if gui not in loop_map:
        e = "Invalid GUI request %r, valid ones are:%s" % (gui, loop_map.keys())
        raise ValueError(e)
    if kernel is None:
        if Application.initialized():
            kernel = getattr(Application.instance(), 'kernel', None)
        if kernel is None:
            raise RuntimeError("You didn't specify a kernel,"
                " and no IPython Application with a kernel appears to be running."
            )
    loop = loop_map[gui]
    if loop and kernel.eventloop is not None and kernel.eventloop is not loop:
        raise RuntimeError("Cannot activate multiple GUI eventloops")
    kernel.eventloop = loop
开发者ID:CaptainAL,项目名称:Spyder,代码行数:18,代码来源:eventloops.py

示例3: is_interactive

# 需要导入模块: from traitlets.config.application import Application [as 别名]
# 或者: from traitlets.config.application.Application import initialized [as 别名]
    def is_interactive(self):
        """ Determine if the user requested interactive mode.
        """
        # The Python interpreter sets sys.flags correctly, so use them!
        if sys.flags.interactive:
            return True

        # IPython does not set sys.flags when -i is specified, so first
        # check it if it is already imported.
        if '__IPYTHON__' not in dir(six.moves.builtins):
            return False

        # Then we check the application singleton and determine based on
        # a variable it sets.
        try:
            try:
                # ipython >=3.0
                from traitlets.config.application import Application as App
            except ImportError:
                # ipython <3.0
                from IPython.config.application import Application as App
            return App.initialized() and App.instance().interact
        except (ImportError, AttributeError):
            return False
开发者ID:Eric89GXL,项目名称:vispy,代码行数:26,代码来源:application.py


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