I am using pyobjc to add some needed OSX functionality to some random python software. I will need to access API-defined objc-land constants from python-land.
An example of such constants lies far down in the NSRunningApplication page, specifically the three possible values of NSApplicationActivationPolicy.
For context, the current task at hand is listing currently running, user-facing applications. To this end, the following code works just fine:
from Foundation import *
from Cocoa import *
import objc
for runningApp in sorted(
NSWorkspace.sharedWorkspace().runningApplications(),
key=lambda x: x.localizedName()
):
if runningApp.activationPolicy() == 0:
# Do stuff
But I'd rather not check against zero (to make it more readable) nor hardcode a dummy NSApplicationActivationPolicyRegular value to zero in my own code when it's readily available in the original library.
How can I access such objc constants from python through pyobjc?