在 Python 中,除了 win10toast
和 plyer
之外,还有其他库可以用于发送桌面通知。以下是一些常用的库及其特点:
1. plyer
- 跨平台支持:支持 Windows、macOS 和 Linux。
- 简单易用:API 设计简洁,适合快速实现通知功能。
- 安装:
pip install plyer
- 示例代码:
from plyer import notification notification.notify( title="This is a title", message="This is a message", app_icon=r"C:\path\to\icon.ico", # 可选 timeout=5 # 持续时间(秒) )
2. notify-py
- 跨平台支持:支持 Windows、macOS 和 Linux。
- 功能丰富:支持自定义图标、声音和按钮等。
- 安装:
pip install notify-py
- 示例代码:
from notifypy import Notify notification = Notify() notification.title = "This is a title" notification.message = "This is a message" notification