0

I'm writing a platform-independent Python application. For now it runs on Linux and OSX. However, I want to integrate platform-specific code. To be more precise I want to use the native notification systems (Growl, Mountain Lion's notification center, GNOME notifications).

So far I managed to integrate the GNOME notifications. The Mountain Lion notifications work fine so far as I used PyObjC to send them. And here is the big problem I ran into:

In order for PyObjC to work properly I need to invoke AppHelper.runEventLoop(). Otherwise, I could send the notifications but I would not be able to react upon clicks on the notifications or anything else that requires the Cocoa libraries to call back my script. But as my application is supposed to be platform independent AppHelper.runEventLoop() is not my desired event loop. I should mention that, despite the notifications, my application is not a GUI application and has in fact its own event loop.

I tried to create an extra thread to run the Cocoa event loop in, without success.

Any ideas?

koloman
  • 711
  • 7
  • 19
  • I ended up running the program logic in a separate thread and using the main thread to run platform-specific event loops. I guess this is the cleanest solution I can get. Anyway, I am curious if there was any other method that would have enabled me to stick with my original design. – koloman Aug 31 '12 at 10:41

1 Answers1

0

You should check out the way this is handled with PyQt (using QApplication): http://en.wikibooks.org/wiki/Python_Programming/PyQt4 . Qt is a solid cross-platform framework which I'd normally recommend using for this type of development.

If using Qt is not an option for you, you could create your own main loop abstraction from NSRunLoop and whatever it is you'll use for Windows & Linux.

user931563
  • 94
  • 1
  • 5