Python post osx notification

后端 未结 7 1174
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 07:08

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 progra

7条回答
  •  星月不相逢
    2020-12-04 07:30

    Another choice is a python lib named pync, maybe it's a better choice. pync is a simple Python wrapper around the terminal-notifier command-line tool, which allows you to send User Notifications to the Notification Center on Mac OS X 10.10, or higher.

    Installation:

    pip install pync

    Examples:

    from pync import Notifier
    
    Notifier.notify('Hello World')
    Notifier.notify('Hello World', title='Python')
    Notifier.notify('Hello World', group=os.getpid())
    Notifier.notify('Hello World', activate='com.apple.Safari')
    Notifier.notify('Hello World', open='http://github.com/')
    Notifier.notify('Hello World', execute='say "OMG"')
    
    Notifier.remove(os.getpid())
    
    Notifier.list(os.getpid())
    

提交回复
热议问题