Windows-10-Toast-Notifications icon indicating copy to clipboard operation
Windows-10-Toast-Notifications copied to clipboard

ClassAtom missing

Open manavrawat10 opened this issue 6 years ago • 5 comments

'ToastNotifier' object has no attribute 'classAtom'

manavrawat10 avatar Apr 22 '18 10:04 manavrawat10

Try to close and open python

ilyamikcoder avatar May 31 '18 10:05 ilyamikcoder

At least one other person has had this problem: https://stackoverflow.com/questions/50741455/toastnotifier-object-has-no-attribute-classatom

This appears to occur when the initial assignment of classAtom fails at https://github.com/jithurjacob/Windows-10-Toast-Notifications/blob/master/win10toast/init.py#L78. Since the except block does nothing but pass, we don't know any details about the error that RegisterClass is throwing. It might be nice to remove the try and except. It wouldn't solve the underlying problem, but it would make it easier to diagnose.

kms70847 avatar Jun 07 '18 12:06 kms70847

Run into the same promlem. Here's the detailed exception:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\Users\username\AppData\Local\Programs\Python\Python37\lib\threading.py", line 917, in _bootstrap_inner
    self.run()
  File "C:\Users\username\AppData\Local\Programs\Python\Python37\lib\threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\username\AppData\Local\Programs\Python\Python37\lib\site-packages\win10toast\__init__.py", line 83, in _show_toast
    self.hwnd = CreateWindow(self.classAtom, "Taskbar", style,
AttributeError: 'ToastNotifier' object has no attribute 'classAtom'

Dobad avatar Jan 08 '19 10:01 Dobad

In my case I lazily was creating a ToastNotifier instance for each notification. Then RegisterClass tells me that the registration has already been done, so it can't register again. So just make sure you create only a single instance of ToastNotifier.

akeeman avatar Jul 17 '19 07:07 akeeman

Thanks @akeeman, I was also doing that! Maybe changing the modus operandi to something like a singleton might protect other people from making the same mistake

badjano avatar Mar 05 '20 02:03 badjano