[Pythonmac-SIG] Python embedded in Cocoa
Jonathan Wight
JWight@bigfoot.com
Sat, 31 Mar 2001 12:32:12 -0600
This isn't necessarily a Mac Python question but I know there's enough
combined knowledge here to help...
I've created a rather basic Cocoa application (ObjC not Java) that has
Python 2.1b2 (not MacPython) embedded in it. I'm hoping to make a primitive
but useable Python IDE for OSX.
It actually works quite well - the user can edit, open and save .py text
files. When he/she clicks the "Run" button the python script executes.
Unfortunately all output goes to stdout which isn't very desirable in a GUI
application.
My current plan is to use a C extension to Python that replaces sys.stdout
and channels all the script's output to a Cocoa NSTextView widget.
Unfortunately I don't really (if I can avoid it) write a full Python object
in C. There seems to be quite a lot of work involved to just replace the
stdout.write method.
Is there a callback or hook somewhere to control what stdout does in an
embedded Python application?
Cheers.
Jon.