Reputation: 28030
I would like to create a simple toast notification using python v3.6 on Windows10 machine.
I am using this python library.
https://github.com/jithurjacob/Windows-10-Toast-Notifications/
I ran the code below;
from win10toast import ToastNotifier
toaster = ToastNotifier()
toaster.show_toast("Hello World!!!",
"Python is awsm by default!")
All I get is an icon appearing at the bottom right. I don't see any message popping out. What are some possible things that can go wrong?
Are there some configuration settings in Windows 10 that disabled the python toast notification?
The screenshot below shows the tiny python icon at the bottom row that appears when I run the python code. I don't see any message such as Hello World!!!","Python is awsm by default!
appearing. When my mouse pointer hover over the python icon, I see the word tooltip
appearing.
Here is my notification settings on Windows 10.
Upvotes: 6
Views: 7784
Reputation: 76
plyer (for creating notifications on your PC)
pip install plyer
creating custom notification
from plyer import notification #for getting notification on your PC
notification.notify(
#title of the notification,
title = "COVID19 Stats",
#the body of the notification
message = "Total cases :",
#creating icon for the notification
#we need to download a icon of ico file format
app_icon = "Paomedia-Small-N-Flat-Bell.ico",
# the notification stays for 50sec
timeout = 50
)
Upvotes: 0
Reputation: 29
I think there is a little mistake in your code. You started the "Python is awsm by default!" text into a new line, but as I remember, if you want to continue the code in the following line, you need to put a backslash to the end of the first line. I also noticed some smaller differences. I know this is hard to understand, so I show you what I am thinking of.
from win10toast import ToastNotifier
toaster = ToastNotifier()
toaster.show_toast("Hello World!!!", \
"Python is awsm by default!")
Upvotes: 2
Reputation: 1169
go to bottom right, click action center, now click at the top right corner where it says manage notifications, now enable the button under the title 'Notifications' if it is disabled and probably because of this reason win10toast was unable to perform the desired task. and now it works absolutely! :) Thank you!
Upvotes: 0
Reputation: 28030
I discovered the solution to my question. The toast notifications have been suppressed by Windows 10 Action Center. At the bottom right corner, click the Action Center icon. For my PC, the "Quiet Hours" setting was turned on. After I disable "Quiet Hours", toast notifications can appear.
The python library win10toast
works perfectly fine after Action Center settings are correctly set.
Upvotes: 14