Toast Notifier is not working, Have i done something wrong?

Viewed 177

First off thanks for taking the time to read this:

I am currently trying to get ToastNotifier working in python in MU. I have imported ToastNotifier from win10toast as such :

from win10toast import ToastNotifier

I have the created this function:

def notifacation():
    toast = ToastNotifier()
    Title = "Notifacation"
    message = "Hello from Ben Colledge"
    icon = "a.ico"
    length = 30
    toast.show_toast(title, message, icon_path=icon, duration=length)

And then called the function like so :

notifacation()

I then run the code and it give me this error message

Traceback (most recent call last):
File "c:\users\puzzl\mu_code\notifacation.py", line 1, in module
from win10toast import ToastNotifier
ModuleNotFoundError: No module named 'win10toast'

I have then gone to https://pypi.org/project/win10toast/ and downloaded win10toast yet nothing happened

Any help would be appreciated Thanks

1 Answers

I had the exact same problem but then I figured out this works best

python.exe -m pip install win10toast

I ran this code and it still has a problem not, although, the same one. Now the bug would be that in the line that has the method.

toast.show_toast(title, message, icon_path=icon, duration=length)

The problem is that 'title' is undefined. The variable that you assigned was named 'Title'. Since Python is case-sensitive, 'title' is an undifined variable. this is what the line should look like now:

toast.show_toast(Title, message, icon_path=icon, duration=length)

Yay! It works now!

Related