-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates on Notification System (fixes #7 )
Mac: Change the notification system to Apple's native notification system. Win: code impovements
- Loading branch information
1 parent
48e92ba
commit 02f0c32
Showing
2 changed files
with
48 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from AppKit import NSImage | ||
from Foundation import NSUserNotification, NSUserNotificationCenter | ||
|
||
class Notification(): | ||
""" The Notification System using Apple's native Notifications System | ||
Attributes: | ||
notification: The notification | ||
center: Apple notification center. | ||
""" | ||
def __init__(self): | ||
self.notification = NSUserNotification.alloc().init() | ||
self.center = NSUserNotificationCenter.defaultUserNotificationCenter() | ||
self.center.setDelegate_(self) | ||
|
||
def userNotificationCenter_shouldPresentNotification_(self, center, notification): | ||
return True | ||
|
||
def clearNotifications(self): | ||
"""Clear any displayed alerts we have posted.""" | ||
self.center.removeAllDeliveredNotifications() | ||
|
||
def notify(self,title,subtitle,text): | ||
"Set notification details and send the notification" | ||
self.notification.setTitle_(title) | ||
self.notification.setSubtitle_(subtitle) | ||
self.notification.setInformativeText_(text) | ||
self.notification.setSoundName_("NSUserNotificationDefaultSoundName") | ||
|
||
self.center.scheduleNotification_(self.notification) |