aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2015-12-07 12:20:49 +0100
committerDave Andreoli <dave@gurumeditation.it>2015-12-07 12:20:49 +0100
commit8e7616c1b39733f675590d942cb2d098f4c5a40c (patch)
treeb5eea58ab80899c331191cf3d769478c03c86baa /examples/elementary
parentjust a note (diff)
downloadpython-efl-8e7616c1b39733f675590d942cb2d098f4c5a40c.tar.gz
Add test/example for Genlist tree
Diffstat (limited to 'examples/elementary')
-rwxr-xr-xexamples/elementary/test.py1
-rw-r--r--examples/elementary/test_genlist_tree.py97
2 files changed, 98 insertions, 0 deletions
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index e1a4e00..486a5fb 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -172,6 +172,7 @@ items = [
("Lists - Genlist", [
("Genlist 1", "test_genlist_1", "test_genlist_1"),
("Genlist 2", "test_genlist_2", "test_genlist_2"),
+ ("Genlist Tree", "test_genlist_tree", "test_genlist_tree"),
("Genlist Group", "test_genlist_group", "test_genlist_group"),
("Genlist Sorted", "test_genlist_sorted", "test_genlist_sorted"),
("Genlist Iteration", "test_genlist_iteration", "test_genlist_iteration"),
diff --git a/examples/elementary/test_genlist_tree.py b/examples/elementary/test_genlist_tree.py
new file mode 100644
index 0000000..c7af141
--- /dev/null
+++ b/examples/elementary/test_genlist_tree.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+import os
+
+from efl.evas import EXPAND_BOTH, FILL_BOTH, EXPAND_HORIZ, FILL_HORIZ
+from efl import elementary as elm
+from efl.elementary import StandardWindow, Box, Check, Icon, Frame, \
+ Genlist, GenlistItemClass, ELM_GENLIST_ITEM_TREE
+
+
+script_path = os.path.dirname(os.path.abspath(__file__))
+img_path = os.path.join(script_path, "images")
+
+
+class MyItemClass(GenlistItemClass):
+ def __init__(self):
+ GenlistItemClass.__init__(self, item_style="tree_effect")
+
+ def text_get(self, obj, part, item_data):
+ return "Item # %i" % item_data
+
+ def content_get(self, obj, part, item_data):
+ if part == 'elm.swallow.icon':
+ ic = Icon(obj, file=os.path.join(img_path, "logo_small.png"))
+ return ic
+
+itc = MyItemClass()
+
+
+# list callbacks
+def list_expand_request_cb(gl, gli):
+ gli.expanded = True
+
+def list_contract_request_cb(gl, gli):
+ gli.expanded = False
+
+def list_expanded_cb(gl, gli):
+ start = gli.data * 10
+ for i in range(start, start + 30):
+ gl.item_append(itc, i, gli, flags=ELM_GENLIST_ITEM_TREE)
+
+def list_contracted_cb(gl, gli):
+ gli.subitems_clear()
+
+
+def test_genlist_tree(parent):
+ win = StandardWindow("Genlist", "Genlist Tree",
+ size=(320, 320), autodel=True)
+
+ # vertical box + options frame
+ box = Box(win, size_hint_expand=EXPAND_BOTH)
+ win.resize_object_add(box)
+ box.show()
+
+ fr = Frame(win, text='Genlist Tree Options',
+ size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
+ box.pack_end(fr)
+ fr.show()
+
+ hbox = Box(win, horizontal=True, homogeneous=True,
+ size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
+ fr.content = hbox
+ hbox.show()
+
+ # Genlist
+ gl = Genlist(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+ gl.callback_expand_request_add(list_expand_request_cb)
+ gl.callback_contract_request_add(list_contract_request_cb)
+ gl.callback_expanded_add(list_expanded_cb)
+ gl.callback_contracted_add(list_contracted_cb)
+ box.pack_end(gl)
+ gl.show()
+
+ gl.item_append(itc, 1, flags=ELM_GENLIST_ITEM_TREE)
+ gl.item_append(itc, 2, flags=ELM_GENLIST_ITEM_TREE)
+ gl.item_append(itc, 3)
+
+ # option buttons
+ ck = Check(win, text='Tree Effect')
+ ck.callback_changed_add(lambda c: setattr(gl, "tree_effect_enabled", c.state))
+ hbox.pack_end(ck)
+ ck.show()
+
+ ck = Check(win, text='Homogeneous')
+ ck.callback_changed_add(lambda c: setattr(gl, "homogeneous", c.state))
+ hbox.pack_end(ck)
+ ck.show()
+
+ # show the window
+ win.show()
+
+
+if __name__ == "__main__":
+ elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
+ test_genlist_tree(None)
+ elm.run()