I am trying to return the current_time or current_time +1 in a func, where I am using the win10toast. My code was working fine before, it just suddenly stopped working. I didn't do anything or change any settings. When running the following code:
from datetime import datetime, timedelta
from win10toast import ToastNotifier
toast = ToastNotifier()
def At_Time():
global Input_time, Ahead_time
At_time = datetime.now()
Ahead_time = (At_time + timedelta(minutes=1))
if timedelta(seconds=At_time.second) < timedelta(seconds=30):
L = 'Less Than 30 secs... Not changing Current_time'
infoL = str('Current Time: ' + At_time.strftime("%H:%M:%S") + '\n' + "Input Time: " + At_time.strftime("%H:%M:%S"))
toast.show_toast(title=L, msg=infoL, duration=7, threaded= True)
Input_time = At_time.strftime("%H:%M")
return Input_time
else:
M = 'More than 30 secs... Adding 1 Min to Current_time'
infoM = str("Current Time: " + At_time.strftime("%H:%M:%S") + '\n' + "Input Time: " + Ahead_time.strftime("%H:%M:%S"))
toast.show_toast(title=M, msg=infoM, duration=7, threaded= True)
Input_time = Ahead_time.strftime("%H:%M")
# meeting_row = Row
return Input_time
At_Time()
When running this, I am now getting the following Error :
`Traceback (most recent call last):
File "C:\Program Files\Python39\lib\threading.py", line 954, in _bootstrap_inner self.run()
File "C:\Program Files\Python39\lib\threading.py", line 892, in run self._target(*self._args, **self._kwargs)
File "C:\Program Files\Python39\lib\site-packages\win10toast\__init__.py", line 106, in
show_toast Shell_NotifyIcon(NIM_ADD, nid)
pywintypes.error: (-2147467259, 'Shell_NotifyIcon', 'Unspecified error')`
Specifically speaking, This is the Error :
pywintypes.error: (-2147467259, 'Shell_NotifyIcon', 'Unspecified error')
I could not find this issue reported anywhere except one https://stackoverflow.com/a/65224994/15136959, where the solution said to use
icon_path= None
This is not going to work as it is already the default value of parameter. I assume the error is associated with the Shell_NotifyIcon(NIM_ADD, nid) , or an Win API Error. This bug/issue is nowhere else mentioned. Can I get reason for this Error, or a fix directly ?
Thanks for the help and your valuable time...
EDIT: This Error got fixed after a Restart. Also during the Restart, Windows got an
"Updating Windows, Do Not Turn Off PC"
, even though I paused the Windows Updates. But still, someone got a permanent fix or even a reason why this occurred, So as to avoid any future issues by other users ??
Lastly, Can a Genius explain.. How can we show multiple notifications by win10toast at the same time, without the Registered Class Error ? ( Optional )