macosx.py 769 B

12345678910111213141516171819202122
  1. import platform
  2. import os
  3. import sys
  4. from pygame.pkgdata import getResource
  5. from pygame import sdlmain_osx
  6. __all__ = ['Video_AutoInit']
  7. def Video_AutoInit():
  8. """Called from the base.c just before display module is initialized."""
  9. if 'Darwin' in platform.platform():
  10. if not sdlmain_osx.RunningFromBundleWithNSApplication():
  11. try:
  12. default_icon_data = getResource('pygame_icon.tiff').read()
  13. except IOError:
  14. default_icon_data = None
  15. except NotImplementedError:
  16. default_icon_data = None
  17. sdlmain_osx.InstallNSApplication(default_icon_data)
  18. if (os.getcwd() == '/') and len(sys.argv) > 1:
  19. os.chdir(os.path.dirname(sys.argv[0]))
  20. return True