Interactive notification windows 10 using python
You can use callback_on_click
method to perform a callback on clicking the notification.
As mentioned in this thread callback_on_click installation you would need to installpip install -e git+https://github.com/Charnelx/Windows-10-Toast-Notifications.git#egg=win10toast
as callback_on_click
is not yet merged with wintoast
.
You will get an error but your new version of toastNotifier
will be copied with the existing one.
You would have to import from src.win10toast.win10toast import ToastNotifier
instead offrom win10toast import ToastNotifier
inorder to access the callback_on_click
method.
Please check the snippet.
from src.win10toast.win10toast import ToastNotifierimport tkinter as tkfrom tkinter import *import webbrowsertop = tk.Tk()top.geometry('50x50')top.title('shop')url = 'http://www.google.com'def notify(): noti.show_toast('Random','Hello World',duration=60, threaded=True,callback_on_click=action) def action(): webbrowser.open_new(url) print("Done") noti = ToastNotifier() btn = Button(top, text= "Enter", command=notify)btn.pack()top.mainloop()
NOTE- Make sure you use threaded=True
in show_toast()
so that the rest of your program will be allowed to execute while the toast is still active. Else your gui would freeze.