https://github.com/jithurjacob/Windows-10-Toast-Notifications/issues/112
提到了你这个错误,其中
It doesn't seem to break anything. It shows up for me after the duration ends, and the toast goes away.
翻译过来就是,这个错误没什么影响,只是在通知结束后会抛出
如果你实在不爽,办法如下:
找到"<你的python安装路径>\Lib\site-packages\win10toast\",里面应该有__main__.py和__init__.py两个文件,打开__init__.py
找到144行,如果没错,应该是on_destroy函数的定义这里,可以看到该函数返回None
- def on_destroy(self, hwnd, msg, wparam, lparam):
- """Clean after notification ended.
- :hwnd:
- :msg:
- :wparam:
- :lparam:
- """
- nid = (self.hwnd, 0)
- Shell_NotifyIcon(NIM_DELETE, nid)
- PostQuitMessage(0)
- return None # 就是这里
复制代码
在https://learn.microsoft.com/en-us/windows/win32/winmsg/wm-destroy#return-value中
Return value
Type: LRESULT
If an application processes this message, it should return zero.
翻译就是该函数需要返回0
所以你只需将最后的return None,改成return 0,就不会报错了