Load program resource files from disk.
The loader contains a search path which can include filesystem directories, ZIP archives and Python packages.
Variables: |
|
---|
Constructor:
Create a loader for the given path.
If no path is specified it defaults to ['.']; that is, just the program directory.
See the module documentation for details on the path format.
Parameters: |
|
---|
Methods:
add_font(name) Add a font resource to the application. animation(name[, flip_x, flip_y, rotate]) Load an animation with optional transformation. attributed(name) Load an attributed text document. file(name[, mode]) Load a resource. get_cached_animation_names() Get a list of animation filenames that have been cached. get_cached_image_names() Get a list of image filenames that have been cached. get_cached_texture_names() Get the names of textures currently cached. get_texture_bins() Get a list of texture bins in use. html(name) Load an HTML document. image(name[, flip_x, flip_y, rotate, atlas]) Load an image with optional transformation. location(name) Get the location of a resource. media(name[, streaming]) Load a sound or video resource. reindex() Refresh the file index. text(name) Load a plain text document. texture(name) Load a texture.
Add a font resource to the application.
Fonts not installed on the system must be added to pyglet before they can be used with font.load. Although the font is added with its filename using this function, it is loaded by specifying its family name. For example:
resource.add_font('action_man.ttf')
action_man = font.load('Action Man')
Parameters: | name (str) – Filename of the font resource to add. |
---|
Load an animation with optional transformation.
Animations loaded from the same source but with different transformations will use the same textures.
Parameters: |
|
---|---|
Return type: | Animation |
Load an attributed text document.
See pyglet.text.formats.attributed for details on this format.
Parameters: | name (str) – Filename of the attribute text resource to load. |
---|---|
Return type: | FormattedDocument |
Load a resource.
Parameters: |
|
---|---|
Return type: | file object |
Get a list of animation filenames that have been cached.
This is useful for debugging and profiling only.
Return type: | list |
---|---|
Returns: | List of str |
Get a list of image filenames that have been cached.
This is useful for debugging and profiling only.
Return type: | list |
---|---|
Returns: | List of str |
Get the names of textures currently cached.
Return type: | list of str |
---|
Get a list of texture bins in use.
This is useful for debugging and profiling only.
Return type: | list |
---|---|
Returns: | List of TextureBin |
Load an HTML document.
Parameters: | name (str) – Filename of the HTML resource to load. |
---|---|
Return type: | FormattedDocument |
Load an image with optional transformation.
This is similar to texture, except the resulting image will be packed into a TextureBin if it is an appropriate size for packing. This is more efficient than loading images into separate textures.
Parameters: |
|
---|---|
Return type: | Texture |
Returns: | A complete texture if the image is large or not in an atlas, otherwise a TextureRegion of a texture atlas. |
Get the location of a resource.
This method is useful for opening files referenced from a resource. For example, an HTML file loaded as a resource might reference some images. These images should be located relative to the HTML file, not looked up individually in the loader’s path.
Parameters: | name (str) – Filename of the resource to locate. |
---|---|
Return type: | Location |
Load a sound or video resource.
The meaning of streaming is as for media.load. Compressed sources cannot be streamed (that is, video and compressed audio cannot be streamed from a ZIP archive).
Parameters: |
|
---|---|
Return type: | media.Source |
Refresh the file index.
You must call this method if path is changed or the filesystem layout changes.
Load a plain text document.
Parameters: | name (str) – Filename of the plain text resource to load. |
---|---|
Return type: | UnformattedDocument |
Load a texture.
The named image will be loaded as a single OpenGL texture. If the dimensions of the image are not powers of 2 a TextureRegion will be returned.
Parameters: | name (str) – Filename of the image resource to load. |
---|---|
Return type: | Texture |