跳转到主要内容

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).. 这将在未来更改。

贡献者


灵感和特别感谢


贡献

欢迎贡献!

请在最新的开发分支上基于您的更改,并为此分支打开一个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 查看哈希值)

上传时间 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面