Specifying the resource path

By default, only the script home directory is searched (the directory containing the __main__ module). You can set pyglet.resource.path to a list of locations to search in order. This list is indexed, so after modifying it you will need to call pyglet.resource.reindex.

Each item in the path list is either a path relative to the script home, or the name of a Python module preceded with an ampersand (@). For example, if you would like to package all your resources in a res directory:

pyglet.resource.path = ['res']
pyglet.resource.reindex()

Items on the path are not searched recursively, so if your resource directory itself has subdirectories, these need to be specified explicitly:

pyglet.resource.path = ['res', 'res/images', 'res/sounds', 'res/fonts']
pyglet.resource.reindex()

Specifying module names makes it easy to group code with its resources. The following example uses the directory containing the hypothetical gui.skins.default for resources:

pyglet.resource.path = ['@gui.skins.default', '.']
pyglet.resource.reindex()