jithurjacob / Windows-10-Toast-Notifications

Python library to display Windows 10 Toast Notifications
MIT License
970 stars 168 forks source link

win10toast not working after converting to exe #29

Open GIskierka opened 6 years ago

GIskierka commented 6 years ago

I write my code in Pycharm and import all the libraries from the built-in pip module. I've done the same with win10toast, and as long as I launch the code from Pycharm it works great, but after converting the project into an executable file the notifications are not shown at all.

Here's the code: import win10toast toaster = win10toast.ToastNotifier() toaster.show_toast("Test", "Hello", duration=5, threaded=True)

I was just testing the library's capabilities so it's just a simple code. I've tried converting it to exe with pyinstaller from windows 10 cmd, as well as py2exe.net

Please let me know if it's just a problem that occurrs on my machine or is it to do with the way the library is written or maybe even with the conversion to exe itself. Thank you in advance.

jithurjacob commented 6 years ago

Please refer to https://github.com/jithurjacob/Windows-10-Toast-Notifications/issues/25

marcelo-franceschini commented 6 years ago

I don't understand why it doens't work only with us, @GIskierka. I tried in my friend's computer, in virtualenv and nothing.

miranquil commented 4 years ago

After more than one year, this issue still not fixed and victims still need to dig solutions out...

hoanghy0112 commented 2 years ago

The problem could be the icon_path parameter hasn't been set You can try my solution here:

from pathlib import Path
OUTPUT_PATH = Path(__file__).parent
ASSETS_PATH = OUTPUT_PATH / Path("./assets")

def relative_to_assets(path: str) -> Path:
    return ASSETS_PATH / Path(path)

toaster = ToastNotifier()
toaster.show_toast("Title", "Message", icon_path=relative_to_assets('../assets/icon.ico'), duration =5)

(My icon file is saved in './assets' folder, your project structure could be different from me)

Note: the path that you pass to relative_to_assets function must be the relative path to your *.ico file

Good luck =)))

SRIKAR-B-S-S commented 2 years ago
import time 
from win10toast import ToastNotifier

if __name__ == '__main__':
    while True:
         toaster = ToastNotifier()
         toaster.show_toast("Hello World!!!", "Python is 10 seconds awsm!",  duration=10, icon_path='')
time.sleep(2)

This is my code, I have kept path of my icon to ''(blank)

but still its isn't still working, I have used AUTO_PY_TO_EXE to convert it to .exe file it just opens and its closed!

I have installed Python 3.10.4 from Windows Store and I have also have Python 3.8.8

my project works well when I open it with 3.10.4 Python but it doesn't work well when opened with 3.8.8 or 3.9.7 too!

When trying to run this with Python(3.9.7 I guess) it is not working

image