我正在试着用python在win 10上做一个祝酒词通知。然而,每次我尝试的时候,我都会得到一个错误,这个错误涉及到一个叫做"shell通知图标“的东西。当我的意思是每次...我尝试了我能找到的每一个库!Notifypy,pynotifier,win10toast,plyer,等等。每次,涉及shell通知图标的相同或近似相同的错误...
以下是其中一个错误:
>>> Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\Elève\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\Elève\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Elève\AppData\Local\Programs\Python\Python37-32\lib\site-packages\plyer\platforms\win\libs\balloontip.py", line 206, in balloon_tip
WindowsBalloonTip(**kwargs)
File "C:\Users\Elève\AppData\Local\Programs\Python\Python37-32\lib\site-packages\plyer\platforms\win\libs\balloontip.py", line 139, in __init__
self.notify(title, message, app_name)
File "C:\Users\Elève\AppData\Local\Programs\Python\Python37-32\lib\site-packages\plyer\platforms\win\libs\balloontip.py", line 188, in notify
raise Exception('Shell_NotifyIconW failed.')
Exception: Shell_NotifyIconW failed.
现在看看第一行,它说明了Thread的一些内容!这是因为我在我的应用程序中使用了线程,你认为这就是它搞砸的原因吗?我怎么能看到并清理我所有的线程呢?
有些人已经问过这个问题了,这里:
pywintypes.error: (-2147467259, 'Shell_NotifyIcon', 'Unspecified error') win10toast python
但是没有人回答,这是另一个库的创建者回答但没有帮助:
Why is this simple python toast notification not working?
在最后一个链接上,解决方案是:
I discovered the solution to my question.
The toast notifications have been suppressed by Windows 10 Action Center.
At the bottom right corner, click the Action Center icon.
For my PC, the "Quiet Hours" setting was turned on. After I disable "Quiet Hours",
toast notifications can appear.
The python library win10toast works perfectly fine after Action Center settings are correctly set
但在所有这些错误出现之前,我的代码已经工作了一点,我可以展示一些敬酒,所以这不是重点……顺便说一句,下面是我的代码:
from pynotifier import Notification
Notification(title='HEAD', description="BODY", duration=3, urgency=Notification.URGENCY_CRITICAL).send()
就像我说的,它工作得很好...直到我开始涉及icon_path参数,因为我想添加一个图标。从那时起,错误..."shell notify图标“是否与我试图更改的图标相关?我甚至不知道它到底是什么!
所以,如果你能帮我得到一个稳定和工作的代码,那就太棒了!谢谢您的提前付款。
编辑: Ok now real wtf...我重新启动了我的计算机,它工作得很好,当天晚些时候,停止了工作……又起作用了..。诸如此类!@.@
发布于 2021-02-04 16:11:27
看起来一切都是自己解决的..。我现在使用:
from plyer import notification
notification.notify('Localisation :', 'France')
但我真的不知道我的错误来自哪里。嗯,所有这些通知库似乎都很不稳定,告诉我“未指明的错误”,所以...Plyer看起来更稳定。
https://stackoverflow.com/questions/66030549
复制相似问题