summaryrefslogtreecommitdiff
path: root/examples/elementary/test_list.py
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2013-02-15 20:41:55 +0000
committerDavide Andreoli <dave@gurumeditation.it>2013-02-15 20:41:55 +0000
commitb58be93f121c2ca240b888d1dd41896d4779927f (patch)
tree371d4e331b3e685e106b211ce3e28b31e9886ada /examples/elementary/test_list.py
parent454d967f848fc563ff504127c87692e430a88318 (diff)
move elementary and emotion tests in a new examples dir. Now tests/ contain only unittest while examples/ all the other tests that need user interaction
SVN revision: 83964
Diffstat (limited to 'examples/elementary/test_list.py')
-rw-r--r--examples/elementary/test_list.py381
1 files changed, 381 insertions, 0 deletions
diff --git a/examples/elementary/test_list.py b/examples/elementary/test_list.py
new file mode 100644
index 0000000..44b58e6
--- /dev/null
+++ b/examples/elementary/test_list.py
@@ -0,0 +1,381 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4from efl import elementary
5from efl import evas
6
7
8def my_list_show_it(obj, it):
9 it.show()
10
11def list_clicked(obj, item=None):
12 win = elementary.Window("list", elementary.ELM_WIN_BASIC)
13 win.title_set("List")
14 win.autodel_set(True)
15
16 bg = elementary.Background(win)
17 win.resize_object_add(bg)
18 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
19 bg.show()
20
21 li = elementary.List(win)
22 win.resize_object_add(li)
23 li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
24
25 ic = elementary.Icon(win)
26 ic.file_set('images/logo_small.png')
27 ic.resizable_set(1, 1)
28 it1 = li.item_append("Hello", ic)
29 ic = elementary.Icon(win)
30 ic.file_set('images/logo_small.png')
31 ic.resizable_set(0, 0)
32 li.item_append("Hello", ic)
33 ic = elementary.Icon(win)
34 ic.standard_set("edit")
35 ic.resizable_set(0, 0)
36 ic2 = elementary.Icon(win)
37 ic2.standard_set("clock")
38 ic2.resizable_set(0, 0)
39 li.item_append(".", ic, ic2)
40
41 ic = elementary.Icon(win)
42 ic.standard_set("delete")
43 ic.resizable_set(0, 0)
44 ic2 = elementary.Icon(win)
45 ic2.standard_set("clock")
46 ic2.resizable_set(0, 0)
47 it2 = li.item_append("How", ic, ic2)
48
49 bx = elementary.Box(win)
50 bx.horizontal_set(True)
51
52 ic = elementary.Icon(win)
53 ic.file_set('images/logo_small.png')
54 ic.resizable_set(0, 0)
55 ic.size_hint_align_set(0.5, 0.5)
56 bx.pack_end(ic)
57 ic.show()
58
59 ic = elementary.Icon(win)
60 ic.file_set('images/logo_small.png')
61 ic.resizable_set(0, 0)
62 ic.size_hint_align_set(0.5, 0.0)
63 bx.pack_end(ic)
64 ic.show()
65
66 ic = elementary.Icon(win)
67 ic.file_set('images/logo_small.png')
68 ic.resizable_set(0, 0)
69 ic.size_hint_align_set(0.0, evas.EVAS_HINT_EXPAND)
70 bx.pack_end(ic)
71 ic.show()
72 li.item_append("are")
73
74 li.item_append("you")
75 it3 = li.item_append("doing")
76 li.item_append("out")
77 li.item_append("there")
78 li.item_append("today")
79 li.item_append("?")
80 it4 = li.item_append("Here")
81 li.item_append("are")
82 li.item_append("some")
83 li.item_append("more")
84 li.item_append("items")
85 li.item_append("Is this label long enough?")
86 it5 = li.item_append("Maybe this one is even longer so we can test long long items.")
87
88 li.go()
89
90 li.show()
91
92 tb2 = elementary.Table(win)
93 tb2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
94 win.resize_object_add(tb2)
95
96 bt = elementary.Button(win)
97 bt.text_set("Hello")
98 bt.callback_clicked_add(my_list_show_it, it1)
99 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
100 bt.size_hint_align_set(0.9, 0.5)
101 tb2.pack(bt, 0, 0, 1, 1);
102 bt.show()
103
104 bt = elementary.Button(win)
105 bt.text_set("How")
106 bt.callback_clicked_add(my_list_show_it, it2)
107 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
108 bt.size_hint_align_set(0.9, 0.5)
109 tb2.pack(bt, 0, 1, 1, 1);
110 bt.show()
111
112 bt = elementary.Button(win)
113 bt.text_set("doing")
114 bt.callback_clicked_add(my_list_show_it, it3)
115 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
116 bt.size_hint_align_set(0.9, 0.5)
117 tb2.pack(bt, 0, 2, 1, 1);
118 bt.show()
119
120 bt = elementary.Button(win)
121 bt.text_set("Here")
122 bt.callback_clicked_add(my_list_show_it, it4)
123 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
124 bt.size_hint_align_set(0.9, 0.5)
125 tb2.pack(bt, 0, 3, 1, 1);
126 bt.show()
127
128 bt = elementary.Button(win)
129 bt.text_set("Maybe this...")
130 bt.callback_clicked_add(my_list_show_it, it5)
131 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
132 bt.size_hint_align_set(0.9, 0.5)
133 tb2.pack(bt, 0, 4, 1, 1);
134 bt.show()
135
136 tb2.show()
137
138 win.resize(320, 320)
139 win.show()
140
141
142def my_list2_clear(bt, li):
143 li.clear()
144
145def my_list2_sel(obj, it):
146 it = obj.selected_item_get()
147 if it is not None:
148 it.selected_set(False)
149
150def list2_clicked(obj, item=None):
151 win = elementary.Window("list-2", elementary.ELM_WIN_BASIC)
152 win.title_set("List 2")
153 win.autodel_set(True)
154
155 bg = elementary.Background(win)
156 bg.file_set('images/plant_01.jpg')
157 win.resize_object_add(bg)
158 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
159 bg.show()
160
161 bx = elementary.Box(win)
162 bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
163 win.resize_object_add(bx)
164 bx.show()
165
166 li = elementary.List(win)
167 li.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
168 li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
169 li.mode_set(elementary.ELM_LIST_LIMIT)
170
171 ic = elementary.Icon(win)
172 ic.file_set('images/logo_small.png')
173 it = li.item_append("Hello", ic, callback=my_list2_sel)
174 it.selected_set(True)
175 ic = elementary.Icon(win)
176 ic.resizable_set(0, 0)
177 ic.file_set('images/logo_small.png')
178 li.item_append("world", ic)
179 ic = elementary.Icon(win)
180 ic.standard_set("edit")
181 ic.resizable_set(0, 0)
182 li.item_append(".", ic)
183
184 ic = elementary.Icon(win)
185 ic.standard_set("delete")
186 ic.resizable_set(0, 0)
187 ic2 = elementary.Icon(win)
188 ic2.standard_set("clock")
189 ic2.resizable_set(0, 0)
190 it2 = li.item_append("How", ic, ic2)
191
192 bx2 = elementary.Box(win)
193 bx2.horizontal_set(True)
194
195 ic = elementary.Icon(win)
196 ic.file_set('images/logo_small.png')
197 ic.resizable_set(0, 0)
198 ic.size_hint_align_set(0.5, 0.5)
199 bx2.pack_end(ic)
200 ic.show()
201
202 ic = elementary.Icon(win)
203 ic.file_set('images/logo_small.png')
204 ic.resizable_set(0, 0)
205 ic.size_hint_align_set(0.5, 0.0)
206 bx2.pack_end(ic)
207 ic.show()
208
209 li.item_append("are", bx2)
210
211 li.item_append("you")
212 li.item_append("doing")
213 li.item_append("out")
214 li.item_append("there")
215 li.item_append("today")
216 li.item_append("?")
217 li.item_append("Here")
218 li.item_append("are")
219 li.item_append("some")
220 li.item_append("more")
221 li.item_append("items")
222 li.item_append("Longer label.")
223
224 li.go()
225
226 bx.pack_end(li)
227 li.show()
228
229 bx2 = elementary.Box(win)
230 bx2.horizontal_set(True)
231 bx2.homogeneous_set(True)
232 bx2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
233 bx2.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
234
235 bt = elementary.Button(win)
236 bt.text_set("Clear")
237 bt.callback_clicked_add(my_list2_clear, li)
238 bt.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
239 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
240 bx2.pack_end(bt)
241 bt.show()
242
243 bx.pack_end(bx2)
244 bx2.show()
245
246 win.resize(320, 320)
247 win.show()
248
249
250def list3_clicked(obj, item=None):
251 win = elementary.Window("list-3", elementary.ELM_WIN_BASIC)
252 win.title_set("List 3")
253 win.autodel_set(True)
254
255 bg = elementary.Background(win)
256 win.resize_object_add(bg)
257 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
258 bg.show()
259
260 li = elementary.List(win)
261 win.resize_object_add(li)
262 li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
263 li.mode_set(elementary.ELM_LIST_COMPRESS)
264
265 ic = elementary.Icon(win)
266 ic.file_set('images/logo_small.png')
267 li.item_append("Hello", ic)
268 ic = elementary.Icon(win)
269 ic.file_set('images/logo_small.png')
270 ic.resizable_set(0, 0)
271 li.item_append("world", ic)
272 ic = elementary.Icon(win)
273 ic.standard_set("edit")
274 ic.resizable_set(0, 0)
275 li.item_append(".", ic)
276
277 ic = elementary.Icon(win)
278 ic.standard_set("delete")
279 ic.resizable_set(0, 0)
280 ic2 = elementary.Icon(win)
281 ic2.standard_set("clock")
282 ic2.resizable_set(0, 0)
283 it2 = li.item_append("How", ic, ic2)
284
285 bx = elementary.Box(win)
286 bx.horizontal_set(True)
287
288 ic = elementary.Icon(win)
289 ic.file_set('images/logo_small.png')
290 ic.resizable_set(0, 0)
291 ic.size_hint_align_set(0.5, 0.5)
292 bx.pack_end(ic)
293 ic.show()
294
295 ic = elementary.Icon(win)
296 ic.file_set('images/logo_small.png')
297 ic.resizable_set(0, 0)
298 ic.size_hint_align_set(0.5, 0.0)
299 bx.pack_end(ic)
300 ic.show()
301
302 ic = elementary.Icon(win)
303 ic.file_set('images/logo_small.png')
304 ic.resizable_set(0, 0)
305 ic.size_hint_align_set(0.0, evas.EVAS_HINT_EXPAND)
306 bx.pack_end(ic)
307 ic.show()
308
309 li.item_append("are", bx)
310 li.item_append("you")
311 li.item_append("doing")
312 li.item_append("out")
313 li.item_append("there")
314 li.item_append("today")
315 li.item_append("?")
316 li.item_append("Here")
317 li.item_append("are")
318 li.item_append("some")
319 li.item_append("more")
320 li.item_append("items")
321 li.item_append("Is this label long enough?")
322 it5 = li.item_append("Maybe this one is even longer so we can test long long items.")
323
324 li.go()
325
326 li.show()
327
328 win.resize(320, 300)
329 win.show()
330
331
332if __name__ == "__main__":
333 def destroy(obj):
334 elementary.exit()
335
336 elementary.init()
337 win = elementary.Window("test", elementary.ELM_WIN_BASIC)
338 win.title_set("python-elementary test application")
339 win.callback_delete_request_add(destroy)
340
341 bg = elementary.Background(win)
342 win.resize_object_add(bg)
343 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
344 bg.show()
345
346 box0 = elementary.Box(win)
347 box0.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
348 win.resize_object_add(box0)
349 box0.show()
350
351 fr = elementary.Frame(win)
352 fr.text_set("Information")
353 box0.pack_end(fr)
354 fr.show()
355
356 lb = elementary.Label(win)
357 lb.text_set("Please select a test from the list below<br>"
358 "by clicking the test button to show the<br>"
359 "test window.")
360 fr.content_set(lb)
361 lb.show()
362
363 items = [("List", list_clicked),
364 ("List 2", list2_clicked),
365 ("List 3", list3_clicked)]
366
367 li = elementary.List(win)
368 li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
369 li.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
370 box0.pack_end(li)
371 li.show()
372
373 for item in items:
374 li.item_append(item[0], callback=item[1])
375
376 li.go()
377
378 win.resize(320,520)
379 win.show()
380 elementary.run()
381 elementary.shutdown()