繁体   English   中英

IPython qtconsole自定义横幅

[英]IPython qtconsole custom banner

我正在尝试为IPython qtconsole(v3.0.0)设置自定义横幅。 在我的配置文件配置中,设置c.IPythonWidget.banner = u'Custom Banner' ,然后启动ipython qtconsole --profile=myprof 我得到的是我的自定义横幅,前面是常规横幅:

Custom BannerPython 2.7.5 (default, Mar  9 2014, 22:15:05) 
Type "copyright", "credits" or "license" for more information.

IPython 3.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
%guiref   -> A brief reference about the graphical user interface.

IPython profile: myprof

In [1]: 

我如何只能打印横幅广告,例如

Custom Banner

IPython profile: myprof

In [1]: 

谢谢。

这并不理想,但是我可以通过在IPython源代码的core/usage.py模块中设置default_gui_banner=""来抑制默认横幅。 如果不修改源代码,我将找不到任何方法(这很丑陋),因此,如果有人有更好的方法,我将不知所措。

不需要的消息被打印为内核横幅的一部分(从其外壳获取)。 通过在其他地方使用/连接到内核之前,将shell的banner1属性设置为空字符串,可以避免打印它:

from IPython.qt.inprocess import QtInProcessKernelManager
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
kernel_manager.kernel.shell.banner1 = ""

我只使用IPython Qt东西进行了测试,因此可能不适用于其他内核。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM