今天偶尔要用到气泡提醒的功能,在网上找了一下相关的python程序代码,找到一个notify-py,具体网址在这里,兴高采烈的pip安装一下,
pip install notify-py
然后照着所提供的源代码运行一下:
from notifypy import Notify
notification = Notify()
notification.title = "Cool Title"
notification.message = "Even cooler message."
缺发现报错了:
Traceback (most recent call last):
File "E:/infohao/bubbleTest.py", line 3, in <module>
notification = Notify()
File "C:\Users\condor\AppData\Roaming\Python\Python36\site-packages\notifypy\notify.py", line 58, in __init__
self._notifier_detect = self._selected_notification_system()
File "C:\Users\condor\AppData\Roaming\Python\Python36\site-packages\notifypy\notify.py", line 96, in _selected_notification_system
f"This version of Windows ({platform.release()}) is not supported."
notifypy.exceptions.UnsupportedPlatform: This version of Windows (7) is not supported. is not supported.
原来对于操作系统有一定的要求:
- Windows 10
- macOS 10 >=10.10
- Linux (libnotify)
经过多方查找,找到一个新的小程序,代码如下:
import time
from plyer import notification
if __name__ == "__main__":
notification.notify(
title="Please Drink Water",
message="Water do eyes, nose, or mouth gets dry? Keeping your body hydrated helps it retain optimum levels of moisture in these sensitive areas, as well as in the blood, bones, an.",
app_icon="icon.ico",
timeout=5
)
time.sleep(10)
具体效果如下:
------------------- 正文到此结束------------------------
推荐一个公众号:健哥聊量化,会持续推出股票相关基础知识,以及python实现的一些基本的分析代码。欢迎大家关注,二维码如下:
相关文章列表如下: