summaryrefslogtreecommitdiff
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
parent76e94bcbf85956f21dc11fd47fbea1a90b9d777b (diff)
Add test/example for Genlist tree
-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 = [
172 ("Lists - Genlist", [ 172 ("Lists - Genlist", [
173 ("Genlist 1", "test_genlist_1", "test_genlist_1"), 173 ("Genlist 1", "test_genlist_1", "test_genlist_1"),
174 ("Genlist 2", "test_genlist_2", "test_genlist_2"), 174 ("Genlist 2", "test_genlist_2", "test_genlist_2"),
175 ("Genlist Tree", "test_genlist_tree", "test_genlist_tree"),
175 ("Genlist Group", "test_genlist_group", "test_genlist_group"), 176 ("Genlist Group", "test_genlist_group", "test_genlist_group"),
176 ("Genlist Sorted", "test_genlist_sorted", "test_genlist_sorted"), 177 ("Genlist Sorted", "test_genlist_sorted", "test_genlist_sorted"),
177 ("Genlist Iteration", "test_genlist_iteration", "test_genlist_iteration"), 178 ("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 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4import os
5
6from efl.evas import EXPAND_BOTH, FILL_BOTH, EXPAND_HORIZ, FILL_HORIZ
7from efl import elementary as elm
8from efl.elementary import StandardWindow, Box, Check, Icon, Frame, \
9 Genlist, GenlistItemClass, ELM_GENLIST_ITEM_TREE
10
11
12script_path = os.path.dirname(os.path.abspath(__file__))
13img_path = os.path.join(script_path, "images")
14
15
16class MyItemClass(GenlistItemClass):
17 def __init__(self):
18 GenlistItemClass.__init__(self, item_style="tree_effect")
19
20 def text_get(self, obj, part, item_data):
21 return "Item # %i" % item_data
22
23 def content_get(self, obj, part, item_data):
24 if part == 'elm.swallow.icon':
25 ic = Icon(obj, file=os.path.join(img_path, "logo_small.png"))
26 return ic
27
28itc = MyItemClass()
29
30
31# list callbacks
32def list_expand_request_cb(gl, gli):
33 gli.expanded = True
34
35def list_contract_request_cb(gl, gli):
36 gli.expanded = False
37
38def list_expanded_cb(gl, gli):
39 start = gli.data * 10
40 for i in range(start, start + 30):
41 gl.item_append(itc, i, gli, flags=ELM_GENLIST_ITEM_TREE)
42
43def list_contracted_cb(gl, gli):
44 gli.subitems_clear()
45
46
47def test_genlist_tree(parent):
48 win = StandardWindow("Genlist", "Genlist Tree",
49 size=(320, 320), autodel=True)
50
51 # vertical box + options frame
52 box = Box(win, size_hint_expand=EXPAND_BOTH)
53 win.resize_object_add(box)
54 box.show()
55
56 fr = Frame(win, text='Genlist Tree Options',
57 size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
58 box.pack_end(fr)
59 fr.show()
60
61 hbox = Box(win, horizontal=True, homogeneous=True,
62 size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
63 fr.content = hbox
64 hbox.show()
65
66 # Genlist
67 gl = Genlist(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
68 gl.callback_expand_request_add(list_expand_request_cb)
69 gl.callback_contract_request_add(list_contract_request_cb)
70 gl.callback_expanded_add(list_expanded_cb)
71 gl.callback_contracted_add(list_contracted_cb)
72 box.pack_end(gl)
73 gl.show()
74
75 gl.item_append(itc, 1, flags=ELM_GENLIST_ITEM_TREE)
76 gl.item_append(itc, 2, flags=ELM_GENLIST_ITEM_TREE)
77 gl.item_append(itc, 3)
78
79 # option buttons
80 ck = Check(win, text='Tree Effect')
81 ck.callback_changed_add(lambda c: setattr(gl, "tree_effect_enabled", c.state))
82 hbox.pack_end(ck)
83 ck.show()
84
85 ck = Check(win, text='Homogeneous')
86 ck.callback_changed_add(lambda c: setattr(gl, "homogeneous", c.state))
87 hbox.pack_end(ck)
88 ck.show()
89
90 # show the window
91 win.show()
92
93
94if __name__ == "__main__":
95 elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
96 test_genlist_tree(None)
97 elm.run()