IPython qtconsole自定义bann

2024-06-06 11:43:18 发布

您现在位置:Python中文网/ 问答频道 /正文

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

我怎样才能只打印我的横幅

^{pr2}$

谢谢。在


Tags: 文件forobjectipythoncustomhelpprofileabout
2条回答

这并不理想,但是我可以通过在IPython源代码的core/usage.py模块中设置default_gui_banner=""来抑制默认横幅。如果不修改源代码(这很难看),我无法找到任何方法来实现这一点,因此,如果有人有更好的方法,我会全神贯注地听。在

您不希望看到的消息作为内核横幅的一部分打印出来(它从shell中获取)。在使用/连接到其他地方的内核之前,我将shell的banner1属性设置为空字符串,从而避免了打印它:

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

我只在ipythonqt中使用过/测试过这个,所以这可能不适用于其他内核。在

相关问题 更多 >