Loader: asynchronous loader, easily extensible.

# Jump directly to Examples

Loader: asynchronous loader, easily extensible.

This is the Asynchronous Loader. You can use it to load an image and use it, even if data are not yet available. You must specify a default loading image for using a such loader

from pymt import *
image = Loader.image('mysprite.png')

You can also load image from url

image = Loader.image('http://mysite.com/test.png')

If you want to change the default loading image, you can do

Loader.loading_image = Image('another_loading.png')
class pymt.loader.LoaderBase

Bases: object

Common base for Loader and specific implementation. By default, Loader will be the best available loader implementation.

The _update() function is called every 1 / 25.s or each frame if we have less than 25 FPS.

error_image

Image used for error (readonly)

image(filename, load_callback=None, post_callback=None)

Load a image using loader. A Proxy image is returned with a loading image

img = Loader.image(filename)
# img will be a ProxyImage.
# You'll use it the same as an Image class.
# Later, when the image is really loaded,
# the loader will change the img.image property
# to the new loaded image
loading_image

Image used for loading (readonly)

run(*largs)

Main loop for the loader.

start()

Start the loader thread/process

stop()

Stop the loader thread/process

class pymt.loader.ProxyImage(arg, **kwargs)

Bases: pymt.core.image.Image, pymt.event.EventDispatcher

Image returned by the Loader.image() function.

Properties :
loaded: bool, default to False

It can be True if the image is already cached

Events :
on_load

Fired when the image is loaded and changed

Examples

File loader.py

from pymt import *

# asynchronous load the image in http
img = Loader.image('http://pymt.eu/styles/logo.png')

# add a container with the core image, and display it
runTouchApp(MTContainer(img))

Table Of Contents

Previous topic

Gesture: Base for gesture recognition.

Next topic

Logger: the PyMT logger

This Page