Skip to main content


Create Notification on Windows using Python | Toast Notification | Popup Notification

Create Notification on Windows using Python | Toast Notification | Popup Notification

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....

Popup Notification
 

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")
#Output_1
Toast Notification


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)
#Output_2
Create Notification on Windows using Python
*Note:- pip Install... commandline is included in the script.

Comments



🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍

Popular Posts

Python underline string, Python underline text, Underline python print

Python pip - Installing modules from IDLE (Pyton GUI) for python 3.7

Top 40 Python - String Processing in Python | Working with String in Python

Python Program - When was I born? / Date of Birth / MY BIRTHDAY (using Python3+)

Top 11 Essential Python Tips and Tricks





Subscribe to our Channel


Follow us on Facebook Page

Join our python facebook groups



Join us on Telegram