On Jun 29, 2011, at 11:23 PM, Thomas Cool wrote:
I'm starting with PyObjC and am having some trouble creating windows
I am not a beginner at either python or cocoa by the way.
Here is what i am trying (both with macports python 2.6 and builtin python 2.6) on 10.6.8
from AppKit import *
simply this returns an error:
Wed Jun 29 16:23:09 TCi7.local python <Error>: kCGErrorInvalidConnection: CGSGetCurrentCursorLocation: Invalid connection
Wed Jun 29 16:23:09 TCi7.local python <Error>: kCGErrorInvalidConnection: CGSNewWindowWithOpaqueShape: Invalid connection
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
objc.error: NSInternalInconsistencyException - Error (1002) creating CGSWindow
Let me guess, you just wrote that into a script, and executed it?
It won't work in Objective-C either, if all you do is just to create a simple executable.
Instead, you need to create an application bundle, using py2app. Otherwise, the window-server refuses to accept connections. I never really bothered to get to know the gory details, but see e.g. this discussion:
And especially the related tech-note.