Thanks for responding so quickly, sorry, I should have included the rest of
my code in my first post. In the .spec file for pyinstaller I have tried
including the images in a folder under 'added_files', that then is included
under 'datas', but that could still be the problem. Here is what my code
looks like for the .spec file, with 'beats' being a folder of .mp3 files
and 'imgs' of jpgs -

added_files = [
            ('beats', 'beats'),
            ('imgs', 'imgs')
]

a = Analysis(['yep.py'],
    pathex = ['/Users/mitchellbarton/workspace/freestylez'],
    binaries = None,
    datas = added_files,
)


and then in my pyglet script -

import os, sys, pyglet
from random import shuffle
from random import randint
import subprocess

# basic app info

if getattr( sys, 'frozen', False ) :
        # running in a bundle
        print('bundle')
else :
        # running live
        print('live')

pyglet.options['audio'] = ('openal', 'silent')
window = pyglet.window.Window(width=400, height=500)
window.activate()
window.set_caption('F R E E S T Y L E Z  ( B A T T L E )')
print('worked')
pic1 = pyglet.resource.image('imgs/ad.jpg')
pic2 = pyglet.resource.image('imgs/ad-2.jpg')
pic3 = pyglet.resource.image('imgs/ad-3.jpg')
pic4 = pyglet.resource.image('imgs/ad-4.jpg')
pic5 = pyglet.resource.image('imgs/ad-5.jpg')
picz = [pic1, pic2, pic3, pic4, pic5]
shuffle(picz)


I will also try your function to get the path of the image and see if it
works.

On Thu, Dec 15, 2016 at 3:52 PM <[email protected]> wrote:

> Thats been a problem sometimes for myself as well, I've found it tricky to
> get working at times. I'll try your approach next time I compile something
> Chris, my own method involves  using a small global function for getting
> the absolute path when loading resources:
> import sys
> import os
>
> box = pyglet.image.load(resource_path('picture.png'))
>
> def resource_path(relative_path):
>     """ Get absolute path to resource, works for dev and for PyInstaller
> """
>     if hasattr(sys, '_MEIPASS'):
>         return os.path.join(sys._MEIPASS, relative_path)
>
>     return os.path.join(os.path.abspath("."), relative_path)
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "pyglet-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pyglet-users/q8diddF_uU8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/pyglet-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to