NSUserNotificationCenter.defaultUserNotificationCenter () returns None using PyInstaller

I'm trying to send a notification to the notification center (Mac OSX) I'm using PyObjC bindings to use cocoa api from our python application.

I am using the following code snippet:

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)¬

When I run directly from python, it works fine and shows a notification in the notification center. However, when I package the program above, using PyInstaller to prepare the binary and run it, it gives the following error.

AttributeError: 'NoneType' object has no attribute 'deliverNotification_'

This means that I do not get the default notification center object.

Has anyone encountered this problem?

Thanks in advance.

+3
source share
1 answer

. , CFBundleIdentifier, App Info.plist, plist, PyInstaller. .

+3

All Articles