win10toast Documentation

repository·master·Indexed 21 days ago

https://github.com/jithurjacob/windows-10-toast-notifications

A lightweight Python library for displaying Windows 10 Toast Notifications. It provides the ToastNotifier class to trigger notifications with customizable titles, messages, icons, and durations, supporting both synchronous and threaded execution.

Tokens
511
Snippets
4
Records
4
Agent score
27%

What's inside win10toast

  1. Show threaded notifications and wait for completion

    master

    By setting threaded=True in show_toast(), the notification will run in its own thread, allowing your main application to continue executing. To prevent the application from exiting before the notification is finished, use toaster.notification_active() in a loop to poll the status.

    import time
    from win10toast import ToastNotifier
    
    toaster = ToastNotifier()
    
    toaster.show_toast("Example two",
                       "This notification is in it's own thread!",
                       icon_path=None,
                       duration=5,
                       threaded=True)
    
    # Wait for threaded notification to finish
    while toaster.notification_active(): 
        time.sleep(0.1)
  2. Display a Windows 10 Toast Notification

    master

    Use the ToastNotifier class to trigger notifications. You can specify the title, message, an optional icon path, and the duration the notification remains visible.

    from win10toast import ToastNotifier
    
    toaster = ToastNotifier()
    toaster.show_toast("Hello World!!!",
                       "Python is 10 seconds awsm!",
                       icon_path="custom.ico",
                       duration=10)