Search code examples
pythoncocoaeventsselectorpyobjc

How to implement pyobjc runConsoleEventLoop()?


For my own python project i need to use the runConsoleEventLoop() method instead of the runEventLoop() both located in PyObjC package.

The problem is that i do not understand the functioning of the runConsoleEventLoop() method and how to implement a custom function that will be started and looped inside the above method.

I have found that the runConsoleEventLoop() call a runMode_beforeDate_ method which can be implemented with a performSelector_target_argument_order_modes_ function, but I can not understand how to do it.

So I kindly ask if someone can write a full example on how to use this feature.

Thanks you all for the help.


Solution

  • The autoreadme.py example contains an example of how to use this function.

    It is basically a helper function to run the NSRunLoop of the current thread with some additional functionality, such as better handling of python exceptions. You don't have to implement methods like runMode_beforeData_ yourself, those are part of the NSRunLoop API.