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