[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pygame from OS X command line



Hi again Bob,

Yes, I'm using current CVS pygame.

From some more investigation, it seems there are two separate problems:

1) Error (1002) creating CGSWindow
This is unrelated to timing -- it happens (with vanilla CVS pygame) with the following script:
python2.4 -i -c "import pygame; pygame.init();screen = pygame.display.set_mode((468, 60))"

However, if I add 'import pygame.macosx;pygame.macosx.init()' before the set_mode, it works.  Just putting macosx.init() after the import in packager_imports() does not work; nor does just importing macosx earlier, without running macosx.init() explicitly.

Investigation shows that, with vanilla CVS pygame, neither macosx.init() nor pygame.packager_imports() is being called before the crash.  I can't work out how macosx.init() or pygame.packager_imports() are supposed to get called normally - my python is weak.

Currently, I'm 'fixing' this with:
pygame.__init__.py:
_check_darwin(): Add
import pygame.macosx
macosx.init()

packager_imports(): Remove:
import pygame.macosx

Will this cause problems?

2) Timing issue
If I fix problem 1, the script above works.  But if I start python2.4, wait a second or two, and then type the same commands manually,  I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/sw/lib/python2.4/site-packages/pygame/macosx.py", line 138, in init
    raise ImportError, "Can not access the window manager.  Use py2app or execute with the pythonw script."
ImportError: Can not access the window manager.  Use py2app or execute with the pythonw script.

This seems to be the error you were telling me about, and it's possible to work around it (by importing pygame quickly) like you mentioned.

Thanks for your help,

Ben