aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-02-26 22:50:25 +0100
committerDave Andreoli <dave@gurumeditation.it>2017-02-26 22:50:25 +0100
commit71354b3bb8a0ec3c22a728a285e455fd1266500b (patch)
treeca8e1215dee296c407a7e59b1fff365a65253c8e /examples/elementary
parentSplit 2 elm.Image tests in 2 files (diff)
downloadpython-efl-71354b3bb8a0ec3c22a728a285e455fd1266500b.tar.gz
New 1.19 API: elm.Image.async_open + 4 new callbacks
with test
Diffstat (limited to 'examples/elementary')
-rwxr-xr-xexamples/elementary/test.py1
-rw-r--r--examples/elementary/test_image_async.py78
2 files changed, 79 insertions, 0 deletions
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index bcb5aa5..3192006 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -157,6 +157,7 @@ items = [
("Icon Standard", "test_icon", "icon_standard_clicked"),
("Image", "test_image", "test_image"),
("Image with memfile", "test_image_memfile", "test_image_memfile"),
+ ("Image async load", "test_image_async", "test_image_async"),
("Photo", "test_photo", "photo_clicked"),
("Photocam", "test_photocam", "photocam_clicked"),
("Slideshow", "test_slideshow", "slideshow_clicked"),
diff --git a/examples/elementary/test_image_async.py b/examples/elementary/test_image_async.py
new file mode 100644
index 0000000..016f5dd
--- /dev/null
+++ b/examples/elementary/test_image_async.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+import os
+
+from efl import elementary as elm
+from efl.elementary import StandardWindow, Box, Image, Check, Button
+from efl.evas import EXPAND_BOTH, FILL_BOTH, EXPAND_HORIZ, FILL_HORIZ
+
+
+script_path = os.path.dirname(os.path.abspath(__file__))
+img_path = os.path.join(script_path, "images")
+img_file = os.path.join(img_path, "insanely_huge_test_image.jpg")
+
+
+def create_image(win):
+ box = win.data["box"]
+ async = win.data["async_chk"].state
+ preload_disabled = win.data["preload_chk"].state
+
+ if "image" in win.data:
+ print("Deleting old image")
+ win.data["image"].delete()
+
+ print("Creating image, async: %s, preload_disabled: %s" % (
+ async, preload_disabled))
+
+ im = Image(win, async_open=async, preload_disabled=preload_disabled,
+ size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+ box.pack_start(im)
+ win.data["image"] = im
+
+ im.callback_load_open_add(lambda i: print("load,open"))
+ im.callback_load_ready_add(lambda i: print("load,ready"))
+ im.callback_load_error_add(lambda i: print("load,error"))
+ im.callback_load_cancel_add(lambda i: print("load,cancel"))
+
+ im.show()
+ im.file = img_file
+
+
+def test_image_async(obj, it=None):
+ win = StandardWindow("image-async", "Image Async Test",
+ autodel=True, size=(320, 480))
+
+ box = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+ win.resize_object_add(box)
+ box.show()
+ win.data["box"] = box
+
+ hbox = Box(box, horizontal=True,
+ size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+ box.pack_end(hbox)
+ hbox.show()
+
+ ck = Check(hbox, text="Async file open")
+ hbox.pack_end(ck)
+ ck.show()
+ win.data["async_chk"] = ck
+
+ ck = Check(hbox, text="Disable preload")
+ hbox.pack_end(ck)
+ ck.show()
+ win.data["preload_chk"] = ck
+
+ bt = Button(box, text="Image Reload")
+ bt.callback_clicked_add(lambda b: create_image(win))
+ box.pack_end(bt)
+ bt.show()
+
+ create_image(win)
+ win.show()
+
+
+if __name__ == "__main__":
+ elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
+ test_image_async(None)
+ elm.run()