Python的跨平台桌面通知库
项目描述
notify.py
为Python脚本和应用程序提供跨平台的桌面通知。
文档
您可以在Git的Wiki上阅读文档,或此处
支持的平台。
- Windows 10/11
- macOS 10 >=10.10
- Linux (libnotify)
除了loguru & jeepney(仅限Linux/DBUS)外,不需要其他依赖项。
安装
pip install notify-py
用法
发送简单通知
from notifypy import Notify
notification = Notify()
notification.title = "Cool Title"
notification.message = "Even cooler message."
notification.send()
发送带图标的通知
from notifypy import Notify
notification = Notify()
notification.title = "Cool Title"
notification.message = "Even cooler message."
notification.icon = "path/to/icon.png"
notification.send()
发送带声音的通知
from notifypy import Notify
notification = Notify()
notification.title = "Cool Title"
notification.message = "Even cooler message."
notification.audio = "path/to/audio/file.wav"
notification.send()
不阻塞发送通知
from notifypy import Notify
notification = Notify()
notification.send(block=False)
使用默认通知标题/消息/图标发送
from notifypy import Notify
notification = Notify(
default_notification_title="Function Message",
default_application_name="Great Application",
default_notification_icon="path/to/icon.png",
default_notification_audio="path/to/sound.wav"
)
def your_function():
# stuff happening here.
notification.message = "Function Result"
notification.send()
命令行界面
安装notify-py时,将提供命令行界面
notifypy --title --message --applicationName --iconPath --soundPath
您可能需要将python3 -m
添加到开头。
重要注意事项
-
截至(2020年5月18日),这只是一个通知服务。无论平台如何,都没有支持嵌入自定义操作(按钮、对话框)。除了告诉您是否发送了shell命令外,还有关于用户在通知上的操作的确认。
-
macOS 不支持 在线自定义图标。您将需要捆绑一个嵌入自定义图标的自定义版本的notifier。
Windows特定。
- 不支持气球提示(预Win10).. 这将在未来更改。
贡献者
灵感和特别感谢
-
https://github.com/go-toast/toast - 将他们的Windows 10 toast通知移植到Python。
-
https://notificationsounds.com/notification-sounds/done-for-you-612 example_notification_sound.wav
贡献
欢迎贡献!
请在最新的开发分支上基于您的更改,并为此分支打开一个PR。不接受master分支的PR。测试会在所有平台上运行。
设置环境
- 安装 Poetry
poetry install
- 添加补丁/新功能/错误修复
- 运行测试
poetry run pytest tests/*
- 运行代码风格检查
poetry run pylint --errors-only notifypy/
- 运行Black格式化
poetry run black notifypy
- 将PR提交到
dev
分支。 - 如果您愿意,可以将您的名字添加到贡献者名单中!
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源代码分发
notify_py-0.3.43.tar.gz (648.1 kB 查看哈希值)
构建分发
notify_py-0.3.43-py3-none-any.whl (649.8 kB 查看哈希值)
关闭
notify_py-0.3.43.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 16ee146d48f16bae5dad233db66014a387efd2c6ed2c4caf1e08aef432070513 |
|
MD5 | 6c191c3bfc406bc0b47ef9d63014757d |
|
BLAKE2b-256 | 062bfc68aeed5108185922c5469484e15c192dff01d61eddfab0c1c256e4f54c |
关闭
notify_py-0.3.43-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 90da686b480bf05d033b21fb5118662bb7a4c68e68cb21d93a048ca7b867f9b4 |
|
MD5 | 52c230db637f5573464aa2360cba972e |
|
BLAKE2b-256 | 87b4649f16520ed0a64c275861dcaf9c1291d079f742aa2bf9102fdd168e4197 |