summaryrefslogtreecommitdiff
path: root/examples/elementary/test_genlist_decorate_all.py
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2015-08-16 16:43:43 +0200
committerDave Andreoli <dave@gurumeditation.it>2015-08-16 16:43:43 +0200
commit28812962d505e05abb78085994f22da57d6d11db (patch)
tree8aaa726f9567b1e48be4d1e20acfe08009a076ff /examples/elementary/test_genlist_decorate_all.py
parent191ce5c22c8e651309f7e84adbba9d51c54c56c4 (diff)
Rewamped genlist tests
* splitted each test in a single file * use new style imports * some other small improvements here and there
Diffstat (limited to 'examples/elementary/test_genlist_decorate_all.py')
-rw-r--r--examples/elementary/test_genlist_decorate_all.py111
1 files changed, 111 insertions, 0 deletions
diff --git a/examples/elementary/test_genlist_decorate_all.py b/examples/elementary/test_genlist_decorate_all.py
new file mode 100644
index 0000000..1ee3ec5
--- /dev/null
+++ b/examples/elementary/test_genlist_decorate_all.py
@@ -0,0 +1,111 @@
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, \
7 EVAS_ASPECT_CONTROL_VERTICAL
8
9from efl import elementary as elm
10from efl.elementary import StandardWindow, Icon, Box, Button, Check, \
11 Genlist, GenlistItem, GenlistItemClass
12
13
14script_path = os.path.dirname(os.path.abspath(__file__))
15img_path = os.path.join(script_path, "images")
16
17
18def edit_icon_clicked_cb(ic, item_data):
19 item = item_data[2]
20 item.delete()
21
22# genlist items class
23class MyItemClass(GenlistItemClass):
24 def text_get(self, obj, part, item_data):
25 return "Item #%i" % (item_data[0])
26
27 def content_get(self, obj, part, item_data):
28 # "edit" EDC layout is like below. each part is swallow part.
29 # the existing item is swllowed to elm.swallow.edit.content part.
30 # --------------------------------------------------------------------
31 # | elm.edit.icon.1 | elm.swallow.decorate.content | elm.edit.icon,2 |
32 # --------------------------------------------------------------------
33
34 if part == "elm.swallow.end":
35 return Icon(obj, file=os.path.join(img_path, "bubble.png"),
36 size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
37 elif part == "elm.edit.icon.1":
38 checked = item_data[1]
39 return Check(obj, state=checked)
40 elif part == "elm.edit.icon.2":
41 ic = Icon(obj, file=os.path.join(img_path, "icon_06.png"),
42 propagate_events=False,
43 size_hint_aspect=(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1))
44 ic.callback_clicked_add(edit_icon_clicked_cb, item_data)
45 return ic
46
47 def delete(self, obj, item_data):
48 print("item deleted.")
49
50
51# genlist callbacks
52def gl_item_selected_cb(gl, it):
53 if gl.decorate_mode:
54 checked = it.data[1]
55 it.data[1] = not checked
56 it.update()
57
58def deco_all_mode_cb(btn, gl):
59 gl.decorate_mode = True
60 gl.select_mode = elm.ELM_OBJECT_SELECT_MODE_ALWAYS
61
62def deco_normal_mode_cb(btn, gl):
63 gl.decorate_mode = False
64 gl.select_mode = elm.ELM_OBJECT_SELECT_MODE_DEFAULT
65
66
67def test_genlist_decorate_all(parent):
68 win = StandardWindow("Genlist", "Genlist Decorate All Mode",
69 size=(520,520), autodel=True)
70
71 bx = Box(win, size_hint_weight=EXPAND_BOTH)
72 win.resize_object_add(bx)
73 bx.show()
74
75 gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
76 gl.callback_selected_add(gl_item_selected_cb)
77 bx.pack_end(gl)
78 gl.show()
79
80 itc = MyItemClass(item_style="default", decorate_all_item_style="edit")
81
82 for i in range(100):
83 item_data = [i, False]
84 it = gl.item_append(itc, item_data)
85 item_data.append(it)
86
87
88 bx2 = Box(win, horizontal=True, homogeneous=True,
89 size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
90 bx.pack_end(bx2)
91 bx2.show()
92
93 bt = Button(win, text="Decorate All mode", size_hint_align=FILL_BOTH,
94 size_hint_weight=EXPAND_HORIZ)
95 bt.callback_clicked_add(deco_all_mode_cb, gl)
96 bx2.pack_end(bt)
97 bt.show()
98
99 bt = Button(win, text="Normal mode", size_hint_align=FILL_BOTH,
100 size_hint_weight=EXPAND_HORIZ)
101 bt.callback_clicked_add(deco_normal_mode_cb, gl)
102 bx2.pack_end(bt)
103 bt.show()
104
105 win.show()
106
107
108if __name__ == "__main__":
109 elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
110 test_genlist_decorate_all(None)
111 elm.run()