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 when using the loader:

from kivy.loader import Loader


You can also load an image from a 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')


バージョン 1.6.0 で追加.

You can tweak the loader to provide a better user experience or more performance, depending of the images you are going to load. Take a look at the parameters:

• Loader.num_workers - define the number of threads to start for loading images.
• Loader.max_upload_per_frame - define the maximum image uploads in GPU to do per frame.
class kivy.loader.LoaderBase[ソース]

ベースクラス: builtins.object

Common base for the Loader and specific implementations. By default, the 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. You can change it by doing:

Loader.error_image = 'error.png'


バージョン 1.6.0 で変更: Not readonly anymore.

image(filename, load_callback=None, post_callback=None, **kwargs)[ソース]

from kivy.app import App
from kivy.uix.image import Image

class TestApp(App):
if proxyImage.image.texture:
self.image.texture = proxyImage.image.texture

def build(self):
self.image = Image()
return self.image

TestApp().run()


loading_image

Loader.loading_image = 'loading.png'


バージョン 1.6.0 で変更: Not readonly anymore.

max_upload_per_frame

The number of images to upload per frame. By default, we’ll upload only 2 images to the GPU per frame. If you are uploading many small images, you can easily increase this parameter to 10 or more. If you are loading multiple full HD images, the upload time may have consequences and block the application. If you want a smooth experience, use the default.

As a matter of fact, a Full-HD RGB image will take ~6MB in memory, so it may take time. If you have activated mipmap=True too, then the GPU must calculate the mipmap of these big images too, in real time. Then it may be best to reduce the max_upload_per_frame to 1 or 2. If you want to get rid of that (or reduce it a lot), take a look at the DDS format.

バージョン 1.6.0 で追加.

num_workers

Number of workers to use while loading (used only if the loader implementation supports it). This setting impacts the loader only on initialization. Once the loader is started, the setting has no impact:

from kivy.loader import Loader


The default value is 2 for giving a smooth user experience. You could increase the number of workers, then all the images will be loaded faster, but the user will not been able to use the application while loading. Prior to 1.6.0, the default number was 20, and loading many full-hd images was completly blocking the application.

バージョン 1.6.0 で追加.

pause()[ソース]

Pause the loader, can be useful during interactions.

バージョン 1.6.0 で追加.

resume()[ソース]

Resume the loader, after a pause().

バージョン 1.6.0 で追加.

run(*largs)[ソース]

start()[ソース]

stop()[ソース]
class kivy.loader.ProxyImage(arg, **kwargs)[ソース]