Notification using python
You can use you plyer to display notifications:
from plyer import notification
notification.notify(
title = "Sample Notification",
message = "This is a sample notification",
timeout = 10
)
Or you can run this code and generate notifications:
from plyer import notification
import tkinter as tk
root = tk.Tk()
tk.Label(root , text = 'NOTIFICATION DEVELOPER').grid(row = 0, column = 0)
tk.Label(root , text = 'Notification Title:').grid(row = 3, column = 0)
tk.Label(root , text = 'Notification Message').grid(row = 4, column = 0)
tk.Label(root , text = 'Seconds for which it appears'). grid(row = 5, column = 0)
t1 = tk.Entry(root)
t1.grid(row = 3, column = 1)
m = tk.Entry(root)
m.grid(row = 4, column = 1)
tm = tk.Entry(root)
tm.grid(row = 5, column = 1)
def strt():
a = int(tm.get())
notification.notify(
title = t1.get(),
message = m.get(),
timeout = a
)
tk.Button(root , text = 'START NOTIFICATION' , command = strt).grid(row = 6, column = 0)
root.mainloop()
If you want he notifications to be displayed again after some time, you can use time.sleep(a) and loop the code. (a = time after which the notification will be displayed again.
For inserting icons, use app_icon:
app_icon = 'Full path of .ico file'
You can use Jason Chen's balloontip.py
for this. It's almost 50 lines of code so I won't be pasting it here.
Seems to work in Windows 10 as well.
Thanks to zack for finding this gem.
There is also Windows-10-Toast-Notifications on Github.
It works on windows 10 (with pywin32) and it allows several notifications.
First, install win10toast by using pip
:
pip install win10toast
Then, import it:
from win10toast import ToastNotifier
Make a variable called toast
:
toast = ToastNotifier()
Show the toast
variable:
toast.show_toast(
"Notification",
"Notification body",
duration = 20,
icon_path = "icon.ico",
threaded = True,
)
It should look something like this: