aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2015-02-16 14:54:26 +0200
committerKai Huuhko <kai.huuhko@gmail.com>2015-02-16 14:54:26 +0200
commit31a6f559b0f461cf64160a79d02e2454981aca87 (patch)
tree488e5e2e5a0083a8e441702808c7a9c9594afe26 /examples/elementary
parentFix the signature of the un/highlight List callback to include the item. (diff)
downloadpython-efl-31a6f559b0f461cf64160a79d02e2454981aca87.tar.gz
Elementary.image: Add memfile support
Diffstat (limited to 'examples/elementary')
-rwxr-xr-xexamples/elementary/test.py1
-rw-r--r--examples/elementary/test_image.py70
2 files changed, 66 insertions, 5 deletions
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index 3bb1abb..0ce1d16 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -147,6 +147,7 @@ items = [
("Icon Transparent", "test_icon", "icon_transparent_clicked"),
("Icon Standard", "test_icon", "icon_standard_clicked"),
("Image", "test_image", "image_clicked"),
+ ("Image with memfile", "test_image", "image2_clicked"),
("Photo", "test_photo", "photo_clicked"),
("Photocam", "test_photocam", "photocam_clicked"),
("Slideshow", "test_slideshow", "slideshow_clicked"),
diff --git a/examples/elementary/test_image.py b/examples/elementary/test_image.py
index c4cfebf..b430369 100644
--- a/examples/elementary/test_image.py
+++ b/examples/elementary/test_image.py
@@ -13,6 +13,9 @@ from efl.elementary.image import Image, ELM_IMAGE_ROTATE_90, \
ELM_IMAGE_FLIP_VERTICAL, ELM_IMAGE_FLIP_TRANSPOSE, ELM_IMAGE_FLIP_TRANSVERSE
from efl.elementary.progressbar import Progressbar
from efl.elementary.separator import Separator
+from efl.elementary.label import Label
+from efl.elementary.frame import Frame
+from efl.elementary.list import List
script_path = os.path.dirname(os.path.abspath(__file__))
@@ -48,7 +51,8 @@ def _cb_im_download_error(im, info, pb):
print("CB DOWNLOAD ERROR [status %s, open_error: %s]" % (info.status, info.open_error))
pb.value = 1.0
-def image_clicked(obj):
+
+def image_clicked(obj, it=None):
win = StandardWindow("image", "Image test", autodel=True, size=(320, 480))
if obj is None:
win.callback_delete_request_add(lambda o: elementary.exit())
@@ -57,7 +61,8 @@ def image_clicked(obj):
win.resize_object_add(vbox)
vbox.show()
- im = Image(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
+ im = Image(
+ win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
file=os.path.join(img_path, "logo.png"))
vbox.pack_end(im)
im.show()
@@ -66,7 +71,8 @@ def image_clicked(obj):
vbox.pack_end(sep)
sep.show()
- hbox = Box(win, layout=ELM_BOX_LAYOUT_FLOW_HORIZONTAL,
+ hbox = Box(
+ win, layout=ELM_BOX_LAYOUT_FLOW_HORIZONTAL,
size_hint_align=FILL_BOTH)
vbox.pack_end(hbox)
hbox.show()
@@ -90,7 +96,8 @@ def image_clicked(obj):
b.callback_clicked_add(lambda b: im.file_set(remote_url))
b.show()
- pb = Progressbar(win, size_hint_weight=EXPAND_BOTH,
+ pb = Progressbar(
+ win, size_hint_weight=EXPAND_BOTH,
size_hint_align=FILL_BOTH)
hbox.pack_end(pb)
pb.show()
@@ -103,10 +110,63 @@ def image_clicked(obj):
win.show()
+def image2_clicked(obj, it=None):
+ win = StandardWindow("image", "Image test", autodel=True, size=(320, 480))
+ if obj is None:
+ win.callback_delete_request_add(lambda o: elementary.exit())
+
+ vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+ win.resize_object_add(vbox)
+
+ im = Image(
+ win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+
+ with open(os.path.join(img_path, "logo.png"), "rb") as fp:
+ image_data = fp.read()
+ im.memfile_set(image_data, len(image_data))
+ vbox.pack_end(im)
+ im.show()
+
+ im = Image(
+ win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+
+ vbox.show()
+ win.show()
+
+
if __name__ == "__main__":
elementary.init()
+ win = StandardWindow(
+ "test", "python-elementary test application",
+ size=(320, 520))
+ win.callback_delete_request_add(lambda o: elementary.exit())
+
+ box0 = Box(win, size_hint_weight=EXPAND_BOTH)
+ win.resize_object_add(box0)
+ box0.show()
- image_clicked(None)
+ lb = Label(win)
+ lb.text_set("Please select a test from the list below<br>"
+ "by clicking the test button to show the<br>"
+ "test window.")
+ lb.show()
+ fr = Frame(win, text="Information", content=lb)
+ box0.pack_end(fr)
+ fr.show()
+
+ items = [("Image", image_clicked),
+ ("Image with memfile", image2_clicked)]
+
+ li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+ box0.pack_end(li)
+ li.show()
+
+ for item in items:
+ li.item_append(item[0], callback=item[1])
+
+ li.go()
+
+ win.show()
elementary.run()
elementary.shutdown()