What is the difference between a threaded and a non-threaded Win10Toast notification in Python?

Viewed 1722

In the win10toast documentation, there are 2 examples of notifications:

from win10toast import ToastNotifier
toaster = ToastNotifier()

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

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)

I ran both and I saw no difference. Apparently, there is no visual difference between them. The timing is also the same - the threaded notification does not take longer to vanish even with the while loop in the end. Both threaded and non-threaded notification do nothing if you click on them.

What is a threaded toast notification? Does it have any difference from the non-threaded one?

1 Answers

When threading is enabled, the rest of your program will be allowed to execute while the toast is still active. Otherwise, your program will wait until the toast has completed before continuing.

Example:

import os
from win10toast import ToastNotifier

toaster = ToastNotifier()

toaster.show_toast('title', 'IE is starting', threaded=True)

os.startfile("C:\\Program Files\\internet explorer\\iexplore.exe")

When threading is set to True, IE will open while the toast is still active.

When threading is set to False, IE will open once the toast ends.

Related