-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotification.py
74 lines (62 loc) · 2.11 KB
/
notification.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import winrt.windows.ui.notifications as notifications
import winrt.windows.data.xml.dom as dom
def send_link_toast(link:str)->None:
#create notifier
nManager = notifications.ToastNotificationManager
notifier = nManager.create_toast_notifier()
#define your notification as string
tString = f"""
<toast launch="-m webbrowser -t {link}">
<visual>
<binding template='ToastGeneric'>
<text>Link Recieved</text>
<text>{link}</text>
</binding>
</visual>
<actions>
<action
content="Open Link"
arguments="-m webbrowser -t {link}"
activationType="foreground"/>
<action
content="Remind me later"
arguments="action=remindlater&contentId=351"
activationType="background"/>
</actions>
</toast>
"""
#convert notification to an XmlDocument
xDoc = dom.XmlDocument()
xDoc.load_xml(tString)
#display notification
notifier.show(notifications.ToastNotification(xDoc))
def send_email_toast(email:str)->None:
#create notifier
nManager = notifications.ToastNotificationManager
notifier = nManager.create_toast_notifier()
#define your notification as string
tString = f"""
<toast launch="-m webbrowser -t mailto:{email}">
<visual>
<binding template='ToastGeneric'>
<text>Send Email to</text>
<text>{email}</text>
</binding>
</visual>
<actions>
<action
content="Compose Email"
arguments="-m webbrowser -t mailto:{email}"
activationType="foreground"/>
<action
content="Remind me later"
arguments="action=remindlater&contentId=351"
activationType="background"/>
</actions>
</toast>
"""
#convert notification to an XmlDocument
xDoc = dom.XmlDocument()
xDoc.load_xml(tString)
#display notification
notifier.show(notifications.ToastNotification(xDoc))