Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show permanent toast if duration is None #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions win10toast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _show_toast(self, title, msg,
:title: notification title
:msg: notification message
:icon_path: path to the .ico file to custom notification
:duration: delay in seconds before notification self-destruction
:duration: delay in seconds before notification self-destruction, None for no-self-destruction
"""
message_map = {WM_DESTROY: self.on_destroy, }

Expand Down Expand Up @@ -109,9 +109,10 @@ def _show_toast(self, title, msg,
hicon, "Balloon Tooltip", msg, 200,
title))
# take a rest then destroy
sleep(duration)
DestroyWindow(self.hwnd)
UnregisterClass(self.wc.lpszClassName, None)
if duration is not None:
sleep(duration)
DestroyWindow(self.hwnd)
UnregisterClass(self.wc.lpszClassName, None)
return None

def show_toast(self, title="Notification", msg="Here comes the message",
Expand All @@ -121,7 +122,7 @@ def show_toast(self, title="Notification", msg="Here comes the message",
:title: notification title
:msg: notification message
:icon_path: path to the .ico file to custom notification
:duration: delay in seconds before notification self-destruction
:duration: delay in seconds before notification self-destruction, None for no-self-destruction
"""
if not threaded:
self._show_toast(title, msg, icon_path, duration)
Expand Down