Python post osx notification

Using python I am wanting to post a message to the OSX Notification Center. What library do I need to use? should i write a program in objective-c and then call that program from python?


How do I access the features of notification center for 10.9 such as the buttons and the text field?


You should install terminal-notifier first with Ruby for example:

$ [sudo] gem install terminal-notifier

And then you can use this code:

import os

# The notifier function
def notify(title, subtitle, message):
    t = '-title {!r}'.format(title)
    s = '-subtitle {!r}'.format(subtitle)
    m = '-message {!r}'.format(message)
    os.system('terminal-notifier {}'.format(' '.join([m, t, s])))

# Calling the function
notify(title    = 'A Real Notification',
       subtitle = 'with python',
       message  = 'Hello, this is me, notifying you!')

And there you go:

enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *