Загрузка изобращения из файла

text/x-python load_imagefile.py — 1 KB

Содержимое файла

Using the asynchronous data loader

How to do it…
We need only a Python file and the URL in this recipe. To complete the recipe:
1. Import the usual kivy package.
2. Import the Image and Loader packages.
3. Import the Widget package.
4. Define the e2App class.
5. Define the _image_Loaded() method, which loads the image in the app.
6. Define the build() method.
7. In this method, load the image in a proxy image.
8. Define the image variable instanced as Image().
9. Return the image variable to display the load image:
import kivy
from kivy.app import App
from kivy.uix.image import Image
from kivy.loader import Loader

class e2App(App):
	def _image_loaded(self, proxyImage):
		if proxyImage.image.texture:
			self.image.texture = proxyImage.image.texture
	def build(self):
		proxyImage = Loader.image(
		self.image = Image()
		return self.image
if __name__ == '__main__':