Tot*_*oum 12 python notify-send python3
我有一个 python3.4 脚本。我想向桌面发送通知。我如何在python中处理这个?我可以使用通知发送吗?
我正在使用 Ubuntu 14.04。
#in my script
if something:
notify-send 'Here is a notification !'
Run Code Online (Sandbox Code Playgroud)
mur*_*uru 23
您可以notify-send
用作外部命令:
import subprocess as s
s.call(['notify-send','foo','bar'])
Run Code Online (Sandbox Code Playgroud)
或者您可以使用notify2
模块 ( sudo apt install python3-notify2
):
import notify2
notify2.init('foo')
n = notify2.Notification('foo', 'bar')
n.show()
Run Code Online (Sandbox Code Playgroud)
包中包含更多示例(请参阅 参考资料/usr/share/doc/python3-notify2/examples/
)。
归档时间: |
|
查看次数: |
19465 次 |
最近记录: |