[Pythonmac-SIG] Using UKKQueue with PyObjC

Bob Ippolito bob at redivi.com
Tue Mar 8 01:23:16 CET 2005


On Mar 7, 2005, at 5:11 PM, Florian Munz wrote:

> Hi,
>
> I'm currently trying to use the UKKQueue class to monitor file changes
> from my PyObjC application.
>
> After some fiddling I got the basics working, but encountered some
> problems and questions:
>
> * What is the minimal way to include such an ObjC wrapper class with
> py2app? I am using the setup.py from RestEdit [1] right now, but this
> looks overly complicated. Also this setup doesn't work when using
> --alias

It's automatically generated from the Xcode project and is a relatively  
general solution, so it's not minimal.  Works fine with --alias here,  
you should try it with py2app svn trunk.

> * I'm using the notifications provided by NSWorkspace:
>
> NSWorkspace.sharedWorkspace().notificationCenter().addObserver_selector 
> _
> name_object_(
>     self, "documentChanged:",
>     None,
>     None)
>
> Is there a way to register an observer which listens to specific  
> objects
> only? UKKQueue sends notifications with the filename as object, but as
> <type 'objc.pyobjc_unicode'> and simply replacing the last None in the
> above method with the filename string didn't work.

Yes you can register a notification that listens for specific objects,  
but that doesn't mean what you think it does.

> * This is more a PyObjC question: Can I use any Python class as a
> delegate for UKKQueue? Or have these to subclass NSObject or something
> else?

You probably can use any Python class, but the most well tested  
solution is to use a NSObject subclass whenever you have code that is  
going to be called from Objective-C, so I would recommend doing that.

-bob



More information about the Pythonmac-SIG mailing list