jithurjacob / Windows-10-Toast-Notifications

Python library to display Windows 10 Toast Notifications
MIT License
964 stars 168 forks source link

fix bug when program create window instance many times #105

Closed sherry0429 closed 2 years ago

sherry0429 commented 2 years ago

fix bug when

for i in range(0, 100):
    toaster.show_toast(...., duration=300)
    time.sleep(1)

and program create window instance many times

and remove destroy window after toast show. now window will be destroy after this:

toast.destroy()

or

with CustomToastNotifier() as toaster:
    toaster....

text codes:

import time

count = 0
with CustomToastNotifier() as toaster:
    while True:
        time.sleep(3)
        toaster.show_toast("Hello World!!!",
                           "Python is 10 seconds awsm!",
                           icon_path="custom.ico",
                           duration=100)
        count += 1
        if count >= 5:
            break