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.

26 lines
972 B

  1. import sys
  2. import os
  3. def is_frozen():
  4. return getattr(sys, 'frozen', False)
  5. def get_resource_path(*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. ("Cannot locate Gooey resources. It seems that the program was frozen, "
  16. "but resource files were not copied into directory of the executable "
  17. "file. Please copy `languages` and `images` folders from gooey module "
  18. "directory into `{}{}` directory. Using PyInstaller, a.datas in .spec "
  19. "file must be specified.".format(resource_dir, os.sep)))
  20. else:
  21. resource_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))
  22. return os.path.join(resource_dir, *args)