You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.1 KiB

  1. import os
  2. import sys
  3. def is_frozen():
  4. return getattr(sys, 'frozen', False)
  5. def getResourcePath(*args):
  6. if is_frozen():
  7. # MEIPASS explanation:
  8. # https://pythonhosted.org/PyInstaller/#run-time-operation
  9. basedir = getattr(sys, '_MEIPASS', None)
  10. if not basedir:
  11. basedir = os.path.dirname(sys.executable)
  12. resource_dir = os.path.join(basedir, 'gooey')
  13. if not os.path.isdir(resource_dir):
  14. raise IOError(
  15. (
  16. "Cannot locate Gooey resources. It seems that the program was frozen, "
  17. "but resource files were not copied into directory of the executable "
  18. "file. Please copy `languages` and `images` folders from gooey module "
  19. "directory into `{}{}` directory. Using PyInstaller, a.datas in .spec "
  20. "file must be specified.".format(resource_dir, os.sep)))
  21. else:
  22. resource_dir = os.path.normpath(
  23. os.path.join(os.path.dirname(__file__), '..', '..'))
  24. return os.path.join(resource_dir, *args)