ysfchn / toasted

Rich toast notifications library for Windows (10/11) in Python, supports all elements provided by Windows.
MIT License
18 stars 1 forks source link

icon on notification not displayed #3

Closed Storik4pro closed 2 months ago

Storik4pro commented 2 months ago

I register the application through the example function and do not see the icon.

def run_example():
    example_register_custom_app_id("Lines.Storik4.goodbyedpiUI", "GoodbyeDPI UI", 'file:///C:/Users\serst\Pictures/asdasd.png')
    asyncio.run(show_battery_example("Lines.Storik4.goodbyedpiUI"))

And app is registering image But, i'm dont seen icon on nonflication image What am I doing wrong?

ysfchn commented 2 months ago

Since you just want to use a local image on your computer as an app icon, you can just register the app ID with Toast.register_app_id normally. The snippet given in the example script is just a shortcut method to use a built-in Windows icon as an app icon. Otherwise, Toast.register_app_id is the recommended way to register an app ID.

To register an app ID:

Toast.register_app_id("Lines.Storik4.goodbyedpiUI", "GoodbyeDPI UI", icon_uri = "C:/Users/serst/Pictures/asdasd.png")

Note that register_app_id method doesn't require the URI scheme (so no file:/// must be used for this one), just the path of the image file where it is located on the computer.

Let me know if you need further help.

Storik4pro commented 2 months ago

I changed the way I register the app, but the icon still doesn't appear in the notification.

def register_app():
    Toast.unregister_app_id('Lines.Storik4.goodbyedpiUI')
    Toast.register_app_id("Lines.Storik4.goodbyedpiUI", "GoodbyeDPI UI", icon_uri = "E:\ByeDPI\data\icon.png")
    example_print_app_ids()

I also tried an existing control panel link as a link to the icon

def register_app():
    Toast.unregister_app_id('Lines.Storik4.goodbyedpiUI')
    Toast.register_app_id("Lines.Storik4.goodbyedpiUI", "GoodbyeDPI UI", icon_uri = "%SystemRoot%\ImmersiveControlPanel\images\logo.png")
    example_print_app_ids()

But this had no effect. I also tried converting python script to exe, but it didn't help

Storik4pro commented 2 months ago

I was able to fix the problem. In "app_id" you should specify the id without "." Examples: asyncio.run(show_message("Lines.Storik4.goodbyedpiUI", title, message))

image

asyncio.run(show_message("GoodbyeDPI_app", title, message))

image

In this case, both keys exist in the registry with the same values

image image

ysfchn commented 2 months ago

App IDs are allowed to contain dots (.) so I don't think that was the problem. I guess it was caused by some sort of Windows caching (maybe a restart can resolve it?) or something else, I'm glad that you are able to resolve it, I will look further into the issue just in case.

Storik4pro commented 2 months ago

Yes, rebooting solves the problem. I didn't think about it at all. Thank you! But, there is also an unpleasant problem that I encountered on another PC during testing. This is an error when writing the application to the registry

image

WinError 1021 "Cannot create a stable subkey under a volatile parent key." can occur if there is already an application on the system that registers the AppUserModelId as temporary. In my case it was Windows Explorer

image

I tried to manually create a partition but received the error "The partition cannot be created. There was an error writing to the registry"

image

The problem was solved by completely manually deleting the AppUserModelId parameter and creating it again as a static parameter.

I don't know if this problem can be solved automatically, but I thought it was worth writing about it here

ysfchn commented 2 months ago

Oh, thanks, didn't knew volatile keys were a thing on Windows, that's new to me. It is strange though that Registry Editor doesn't indicate anything if a key or sub key is volatile.

Maybe I can check if I can make Toasted to create registry keys as volatile, so keys won't persist in the system. Also, I don't recommend completely deleting AppUserModelId key and re-creating it since it may contain other app IDs which are used by other applications. You should only delete the subkey that Toasted has created. AppUserModelId is assumed to be created by Windows.

ysfchn commented 2 months ago

Closing this issue since the app icon seems being set without an issue from Toasted-side, but I created #4 for setting keys as volatile.