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


Python InteractiveShellApp.init_gui_pylab方法代码示例

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


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

示例1: init_gui_pylab

# 需要导入模块: from IPython.core.shellapp import InteractiveShellApp [as 别名]
# 或者: from IPython.core.shellapp.InteractiveShellApp import init_gui_pylab [as 别名]
    def init_gui_pylab(self):
        """Enable GUI event loop integration, taking pylab into account."""

        # Register inline backend as default
        # this is higher priority than matplotlibrc,
        # but lower priority than anything else (mpl.use() for instance).
        # This only affects matplotlib >= 1.5
        if not os.environ.get('MPLBACKEND'):
            os.environ['MPLBACKEND'] = 'module://ipykernel.pylab.backend_inline'

        # Provide a wrapper for :meth:`InteractiveShellApp.init_gui_pylab`
        # to ensure that any exception is printed straight to stderr.
        # Normally _showtraceback associates the reply with an execution,
        # which means frontends will never draw it, as this exception
        # is not associated with any execute request.

        shell = self.shell
        _showtraceback = shell._showtraceback
        try:
            # replace error-sending traceback with stderr
            def print_tb(etype, evalue, stb):
                print ("GUI event loop or pylab initialization failed",
                       file=sys.stderr)
                print (shell.InteractiveTB.stb2text(stb), file=sys.stderr)
            shell._showtraceback = print_tb
            InteractiveShellApp.init_gui_pylab(self)
        finally:
            shell._showtraceback = _showtraceback
开发者ID:dalejung,项目名称:ipykernel,代码行数:30,代码来源:kernelapp.py

示例2: init_gui_pylab

# 需要导入模块: from IPython.core.shellapp import InteractiveShellApp [as 别名]
# 或者: from IPython.core.shellapp.InteractiveShellApp import init_gui_pylab [as 别名]
    def init_gui_pylab(self):
        """Enable GUI event loop integration, taking pylab into account."""

        # Provide a wrapper for :meth:`InteractiveShellApp.init_gui_pylab`
        # to ensure that any exception is printed straight to stderr.
        # Normally _showtraceback associates the reply with an execution,
        # which means frontends will never draw it, as this exception
        # is not associated with any execute request.

        shell = self.shell
        _showtraceback = shell._showtraceback
        try:
            # replace error-sending traceback with stderr
            def print_tb(etype, evalue, stb):
                print ("GUI event loop or pylab initialization failed",
                       file=io.stderr)
                print (shell.InteractiveTB.stb2text(stb), file=io.stderr)
            shell._showtraceback = print_tb
            InteractiveShellApp.init_gui_pylab(self)
        finally:
            shell._showtraceback = _showtraceback
开发者ID:Agent74,项目名称:ipython,代码行数:23,代码来源:kernelapp.py


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