blob: a52ebe375f42ad54e7f42ce41d1b3c69cf2d29bd (
plain) (
blame)
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
|
from plyer.facades import Notification
import Foundation
import objc
import AppKit
class OSXNotification(Notification):
def _notify(self, **kwargs):
NSUserNotification = objc.lookUpClass('NSUserNotification')
NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')
notification = NSUserNotification.alloc().init()
notification.setTitle_(kwargs.get('title').encode('utf-8'))
#notification.setSubtitle_(str(subtitle))
notification.setInformativeText_(kwargs.get('message').encode('utf-8'))
notification.setSoundName_("NSUserNotificationDefaultSoundName")
#notification.setHasActionButton_(False)
#notification.setOtherButtonTitle_("View")
#notification.setUserInfo_({"action":"open_url", "value":url})
NSUserNotificationCenter.defaultUserNotificationCenter() \
.setDelegate_(self)
NSUserNotificationCenter.defaultUserNotificationCenter() \
.scheduleNotification_(notification)
def instance():
return OSXNotification()
|