I stumbled upon Ragestorm.net’s great tutorial on Python embedding when I was trying to embed Python in a Cocoa application and redirect standard output / standard error to an NSTextView. Ragestorm’s tutorial is not particularly about Cocoa / Objective-C, but does though solve the problem. Stdout / stderr is simply redirected using a fragment of Python code, which is injected directly after the Python runtime is loaded. It makes use of a couple of C-functions provided by the host application, which connect the Python output to the Cocoa-based NSTextView.
I have uploaded the Python Console Sample Xcode project containing all the code. I think it’s pretty self-explanatory. Have fun!





0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment