2014-02-25 83 views
10

如何讓IPython在命令執行時通知我?我可以讓它使用鈴聲/提醒,還是彈出?我在OS X 10.8.5上運行iTerm上的Anaconda。執行/命令完成時通知

+0

您是否希望在每個命令時自動發生這種情況,或者只有在命令末尾鍵入一些'notify_me()'時纔會發生這種情況? – asmeurer

回答

0

當不可見標籤中輸出時,最新版本的iTerm會向通知中心發送通知。默認情況下,它們會摺疊到通知中心,但您可以將它們更改爲保留在系統偏好設置的通知首選項中的屏幕上。

+0

這從來沒有爲我工作。你需要購買並安裝咆哮嗎? – psquid

+0

@Psquid看到我的其他答案。 – asmeurer

0

作爲替代方案,我寫了一個單模/裝飾功能通知功能上完成(僅適用於MAC)

實施例:

from ipynotifyer import notifyOnComplete as nf 


@nf() 
def divide_by_five(): 
    return 5/5 

@nf(timer=True) 
def divide_by_ten(): 
    return 5/10 

https://github.com/Casyfill/ipython_notifier

4

終於有人created a nice library for it

你只需要安裝它:

pip install jupyternotify 

導入它在你的筆記本:

import jupyternotify 
ip = get_ipython() 
ip.register_magics(jupyternotify.JupyterNotifyMagics) 

,並使用魔法命令:

%%notify 
import time 
time.sleep(5) 

,並得到一個不錯的通知:

enter image description here

Git頁面還顯示如何自動加載它。

相關問題