2

我正在尝试为 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]: 

谢谢。

4

2 回答 2

0

这并不理想,但我能够通过 在 IPython 源代码default_gui_banner=""中的模块中进行设置来抑制默认横幅。core/usage.py如果不修改源(这很丑陋),我无法找到任何方法来做到这一点,所以如果有人有更好的方法,我会全神贯注。

于 2015-05-12T20:40:03.677 回答
0

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

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

我只使用/测试过 IPython Qt 的东西,所以这可能不适用于其他内核。

于 2015-06-29T18:43:12.007 回答