Ever wondered what if you could customize notification on windows and print text according to your needs. Or a Reminder like an Alarm Clock or a Scheduled task that gives you popup notification also called toast notification which is on the bottom right of your screen.
Which would look something like this....
It would come handy if you could control them according to your needs. So how to do that?
Well, its just a few lines of code. So lets start with a code.
Our First format we will create a simple notification, and its only job is to popup with some text on it.
# pip install win10toast from win10toast import ToastNotifier toaster = ToastNotifier() #Show Notification On Windows. #Download icon and name it as icon.ico in the same folder. toaster.show_toast("Title - Hello World of Python4Fun", "Description Text of python4fun", duration=7, icon_path="icon.ico")
Our Second format we will create similar notification type but this time it will have the feature of click which will lead us to a website of the given URL.
# pip install win10toast-click from win10toast_click import ToastNotifier import webbrowser toaster = ToastNotifier() url = "https://pysnakeblog.blogspot.com" def open_url(): try: webbrowser.open_new(url) print("Opening URL...") except: print("Sorry, failed to open URL!") #Show Notification On Windows. #Download icon and name it as icon.ico in the same folder. toaster.show_toast("Welcome to Python4Fun", "Click Here to Open >> ", duration=7, icon_path="icon.ico", threaded=True, callback_on_click=open_url)
*Note:- pip Install... commandline is included in the script.
Comments
Post a Comment