【发布时间】:2014-08-08 13:36:23
【问题描述】:
我正在尝试将通知发送到通知中心 (Mac OSX) 我正在使用 PyObjC 绑定来使用我们 Python 应用程序中的可可 api。
我正在使用以下代码 sn-p :
import Foundation¬
import objc¬
NSUserNotification = objc.lookUpClass('NSUserNotification')¬
NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')¬
notification = NSUserNotification.alloc().init()¬
notification.setTitle_("TestTitle")¬
notification.setInformativeText_("This is sample text")¬
center = NSUserNotificationCenter.defaultUserNotificationCenter()¬
center.deliverNotification_(notification)¬
当我直接从 python 上面运行时,它运行良好并在通知中心显示通知。但是,当我使用 PyInstaller 打包上述程序以准备二进制文件并运行时,它会出现以下错误。
AttributeError: 'NoneType' object has no attribute 'deliverNotification_'
这意味着我没有得到默认用户通知中心的对象。
有人遇到过这个问题吗?
提前致谢。
【问题讨论】:
-
py2app 上的类似问题有时会回来stackoverflow.com/questions/19678342/…
标签: python macos pyinstaller pyobjc