Skip to content

Instantly share code, notes, and snippets.

@zooba
Created September 8, 2020 08:47
Show Gist options
  • Save zooba/e21e204c9e79b0d6d76e7ddede501eb5 to your computer and use it in GitHub Desktop.
Save zooba/e21e204c9e79b0d6d76e7ddede501eb5 to your computer and use it in GitHub Desktop.
Popping up a toast notification using the winrt library
from winrt.windows.ui.notifications import ToastNotificationManager, ToastNotification, ToastTemplateType
def toast(title, text):
xml = ToastNotificationManager.get_template_content(ToastTemplateType.TOAST_TEXT02)
ee = xml.get_elements_by_tag_name("text")
ee[0].append_child(xml.create_text_node(title))
ee[1].append_child(xml.create_text_node(text))
notifier = ToastNotificationManager.create_toast_notifier()
notifier.show(ToastNotification(xml))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment