簡體   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