summaryrefslogtreecommitdiff
path: root/examples/elementary/test_list.py
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2013-03-01 21:01:50 +0000
committerDavide Andreoli <dave@gurumeditation.it>2013-03-01 21:01:50 +0000
commit0873fe162131bf672245e51d2670fc1ce822cfdd (patch)
tree4fa8667a51105ad846560dafe7e8fe64d935e616 /examples/elementary/test_list.py
parente02e6491d4d7902df7c326e98d5a061a6bc3fccf (diff)
Do not import EVERY widget while importing efl.elementary
Now the user is responsable of importing the widget used one by one, this should be a great speedup in the launch of the app. You have to import stuff in this way: from efl import evas from efl import elementary from efl.elementary.window import Window from efl.elementary.layout import Layout ...sorry for the inconvenience SVN revision: 84402
Diffstat (limited to 'examples/elementary/test_list.py')
-rw-r--r--examples/elementary/test_list.py113
1 files changed, 61 insertions, 52 deletions
diff --git a/examples/elementary/test_list.py b/examples/elementary/test_list.py
index 44b58e6..3ce86bb 100644
--- a/examples/elementary/test_list.py
+++ b/examples/elementary/test_list.py
@@ -1,69 +1,78 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2# encoding: utf-8 2# encoding: utf-8
3 3
4from efl import elementary
5from efl import evas 4from efl import evas
5from efl import elementary
6from efl.elementary.window import Window
7from efl.elementary.background import Background
8from efl.elementary.box import Box
9from efl.elementary.button import Button
10from efl.elementary.frame import Frame
11from efl.elementary.label import Label
12from efl.elementary.list import List
13from efl.elementary.icon import Icon
14from efl.elementary.table import Table
6 15
7 16
8def my_list_show_it(obj, it): 17def my_list_show_it(obj, it):
9 it.show() 18 it.show()
10 19
11def list_clicked(obj, item=None): 20def list_clicked(obj, item=None):
12 win = elementary.Window("list", elementary.ELM_WIN_BASIC) 21 win = Window("list", elementary.ELM_WIN_BASIC)
13 win.title_set("List") 22 win.title_set("List")
14 win.autodel_set(True) 23 win.autodel_set(True)
15 24
16 bg = elementary.Background(win) 25 bg = Background(win)
17 win.resize_object_add(bg) 26 win.resize_object_add(bg)
18 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 27 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
19 bg.show() 28 bg.show()
20 29
21 li = elementary.List(win) 30 li = List(win)
22 win.resize_object_add(li) 31 win.resize_object_add(li)
23 li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 32 li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
24 33
25 ic = elementary.Icon(win) 34 ic = Icon(win)
26 ic.file_set('images/logo_small.png') 35 ic.file_set('images/logo_small.png')
27 ic.resizable_set(1, 1) 36 ic.resizable_set(1, 1)
28 it1 = li.item_append("Hello", ic) 37 it1 = li.item_append("Hello", ic)
29 ic = elementary.Icon(win) 38 ic = Icon(win)
30 ic.file_set('images/logo_small.png') 39 ic.file_set('images/logo_small.png')
31 ic.resizable_set(0, 0) 40 ic.resizable_set(0, 0)
32 li.item_append("Hello", ic) 41 li.item_append("Hello", ic)
33 ic = elementary.Icon(win) 42 ic = Icon(win)
34 ic.standard_set("edit") 43 ic.standard_set("edit")
35 ic.resizable_set(0, 0) 44 ic.resizable_set(0, 0)
36 ic2 = elementary.Icon(win) 45 ic2 = Icon(win)
37 ic2.standard_set("clock") 46 ic2.standard_set("clock")
38 ic2.resizable_set(0, 0) 47 ic2.resizable_set(0, 0)
39 li.item_append(".", ic, ic2) 48 li.item_append(".", ic, ic2)
40 49
41 ic = elementary.Icon(win) 50 ic = Icon(win)
42 ic.standard_set("delete") 51 ic.standard_set("delete")
43 ic.resizable_set(0, 0) 52 ic.resizable_set(0, 0)
44 ic2 = elementary.Icon(win) 53 ic2 = Icon(win)
45 ic2.standard_set("clock") 54 ic2.standard_set("clock")
46 ic2.resizable_set(0, 0) 55 ic2.resizable_set(0, 0)
47 it2 = li.item_append("How", ic, ic2) 56 it2 = li.item_append("How", ic, ic2)
48 57
49 bx = elementary.Box(win) 58 bx = Box(win)
50 bx.horizontal_set(True) 59 bx.horizontal_set(True)
51 60
52 ic = elementary.Icon(win) 61 ic = Icon(win)
53 ic.file_set('images/logo_small.png') 62 ic.file_set('images/logo_small.png')
54 ic.resizable_set(0, 0) 63 ic.resizable_set(0, 0)
55 ic.size_hint_align_set(0.5, 0.5) 64 ic.size_hint_align_set(0.5, 0.5)
56 bx.pack_end(ic) 65 bx.pack_end(ic)
57 ic.show() 66 ic.show()
58 67
59 ic = elementary.Icon(win) 68 ic = Icon(win)
60 ic.file_set('images/logo_small.png') 69 ic.file_set('images/logo_small.png')
61 ic.resizable_set(0, 0) 70 ic.resizable_set(0, 0)
62 ic.size_hint_align_set(0.5, 0.0) 71 ic.size_hint_align_set(0.5, 0.0)
63 bx.pack_end(ic) 72 bx.pack_end(ic)
64 ic.show() 73 ic.show()
65 74
66 ic = elementary.Icon(win) 75 ic = Icon(win)
67 ic.file_set('images/logo_small.png') 76 ic.file_set('images/logo_small.png')
68 ic.resizable_set(0, 0) 77 ic.resizable_set(0, 0)
69 ic.size_hint_align_set(0.0, evas.EVAS_HINT_EXPAND) 78 ic.size_hint_align_set(0.0, evas.EVAS_HINT_EXPAND)
@@ -89,11 +98,11 @@ def list_clicked(obj, item=None):
89 98
90 li.show() 99 li.show()
91 100
92 tb2 = elementary.Table(win) 101 tb2 = Table(win)
93 tb2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 102 tb2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
94 win.resize_object_add(tb2) 103 win.resize_object_add(tb2)
95 104
96 bt = elementary.Button(win) 105 bt = Button(win)
97 bt.text_set("Hello") 106 bt.text_set("Hello")
98 bt.callback_clicked_add(my_list_show_it, it1) 107 bt.callback_clicked_add(my_list_show_it, it1)
99 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 108 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
@@ -101,7 +110,7 @@ def list_clicked(obj, item=None):
101 tb2.pack(bt, 0, 0, 1, 1); 110 tb2.pack(bt, 0, 0, 1, 1);
102 bt.show() 111 bt.show()
103 112
104 bt = elementary.Button(win) 113 bt = Button(win)
105 bt.text_set("How") 114 bt.text_set("How")
106 bt.callback_clicked_add(my_list_show_it, it2) 115 bt.callback_clicked_add(my_list_show_it, it2)
107 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 116 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
@@ -109,7 +118,7 @@ def list_clicked(obj, item=None):
109 tb2.pack(bt, 0, 1, 1, 1); 118 tb2.pack(bt, 0, 1, 1, 1);
110 bt.show() 119 bt.show()
111 120
112 bt = elementary.Button(win) 121 bt = Button(win)
113 bt.text_set("doing") 122 bt.text_set("doing")
114 bt.callback_clicked_add(my_list_show_it, it3) 123 bt.callback_clicked_add(my_list_show_it, it3)
115 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 124 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
@@ -117,7 +126,7 @@ def list_clicked(obj, item=None):
117 tb2.pack(bt, 0, 2, 1, 1); 126 tb2.pack(bt, 0, 2, 1, 1);
118 bt.show() 127 bt.show()
119 128
120 bt = elementary.Button(win) 129 bt = Button(win)
121 bt.text_set("Here") 130 bt.text_set("Here")
122 bt.callback_clicked_add(my_list_show_it, it4) 131 bt.callback_clicked_add(my_list_show_it, it4)
123 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 132 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
@@ -125,7 +134,7 @@ def list_clicked(obj, item=None):
125 tb2.pack(bt, 0, 3, 1, 1); 134 tb2.pack(bt, 0, 3, 1, 1);
126 bt.show() 135 bt.show()
127 136
128 bt = elementary.Button(win) 137 bt = Button(win)
129 bt.text_set("Maybe this...") 138 bt.text_set("Maybe this...")
130 bt.callback_clicked_add(my_list_show_it, it5) 139 bt.callback_clicked_add(my_list_show_it, it5)
131 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 140 bt.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
@@ -148,58 +157,58 @@ def my_list2_sel(obj, it):
148 it.selected_set(False) 157 it.selected_set(False)
149 158
150def list2_clicked(obj, item=None): 159def list2_clicked(obj, item=None):
151 win = elementary.Window("list-2", elementary.ELM_WIN_BASIC) 160 win = Window("list-2", elementary.ELM_WIN_BASIC)
152 win.title_set("List 2") 161 win.title_set("List 2")
153 win.autodel_set(True) 162 win.autodel_set(True)
154 163
155 bg = elementary.Background(win) 164 bg = Background(win)
156 bg.file_set('images/plant_01.jpg') 165 bg.file_set('images/plant_01.jpg')
157 win.resize_object_add(bg) 166 win.resize_object_add(bg)
158 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 167 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
159 bg.show() 168 bg.show()
160 169
161 bx = elementary.Box(win) 170 bx = Box(win)
162 bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 171 bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
163 win.resize_object_add(bx) 172 win.resize_object_add(bx)
164 bx.show() 173 bx.show()
165 174
166 li = elementary.List(win) 175 li = List(win)
167 li.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) 176 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) 177 li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
169 li.mode_set(elementary.ELM_LIST_LIMIT) 178 li.mode_set(elementary.ELM_LIST_LIMIT)
170 179
171 ic = elementary.Icon(win) 180 ic = Icon(win)
172 ic.file_set('images/logo_small.png') 181 ic.file_set('images/logo_small.png')
173 it = li.item_append("Hello", ic, callback=my_list2_sel) 182 it = li.item_append("Hello", ic, callback=my_list2_sel)
174 it.selected_set(True) 183 it.selected_set(True)
175 ic = elementary.Icon(win) 184 ic = Icon(win)
176 ic.resizable_set(0, 0) 185 ic.resizable_set(0, 0)
177 ic.file_set('images/logo_small.png') 186 ic.file_set('images/logo_small.png')
178 li.item_append("world", ic) 187 li.item_append("world", ic)
179 ic = elementary.Icon(win) 188 ic = Icon(win)
180 ic.standard_set("edit") 189 ic.standard_set("edit")
181 ic.resizable_set(0, 0) 190 ic.resizable_set(0, 0)
182 li.item_append(".", ic) 191 li.item_append(".", ic)
183 192
184 ic = elementary.Icon(win) 193 ic = Icon(win)
185 ic.standard_set("delete") 194 ic.standard_set("delete")
186 ic.resizable_set(0, 0) 195 ic.resizable_set(0, 0)
187 ic2 = elementary.Icon(win) 196 ic2 = Icon(win)
188 ic2.standard_set("clock") 197 ic2.standard_set("clock")
189 ic2.resizable_set(0, 0) 198 ic2.resizable_set(0, 0)
190 it2 = li.item_append("How", ic, ic2) 199 it2 = li.item_append("How", ic, ic2)
191 200
192 bx2 = elementary.Box(win) 201 bx2 = Box(win)
193 bx2.horizontal_set(True) 202 bx2.horizontal_set(True)
194 203
195 ic = elementary.Icon(win) 204 ic = Icon(win)
196 ic.file_set('images/logo_small.png') 205 ic.file_set('images/logo_small.png')
197 ic.resizable_set(0, 0) 206 ic.resizable_set(0, 0)
198 ic.size_hint_align_set(0.5, 0.5) 207 ic.size_hint_align_set(0.5, 0.5)
199 bx2.pack_end(ic) 208 bx2.pack_end(ic)
200 ic.show() 209 ic.show()
201 210
202 ic = elementary.Icon(win) 211 ic = Icon(win)
203 ic.file_set('images/logo_small.png') 212 ic.file_set('images/logo_small.png')
204 ic.resizable_set(0, 0) 213 ic.resizable_set(0, 0)
205 ic.size_hint_align_set(0.5, 0.0) 214 ic.size_hint_align_set(0.5, 0.0)
@@ -226,13 +235,13 @@ def list2_clicked(obj, item=None):
226 bx.pack_end(li) 235 bx.pack_end(li)
227 li.show() 236 li.show()
228 237
229 bx2 = elementary.Box(win) 238 bx2 = Box(win)
230 bx2.horizontal_set(True) 239 bx2.horizontal_set(True)
231 bx2.homogeneous_set(True) 240 bx2.homogeneous_set(True)
232 bx2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0) 241 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) 242 bx2.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
234 243
235 bt = elementary.Button(win) 244 bt = Button(win)
236 bt.text_set("Clear") 245 bt.text_set("Clear")
237 bt.callback_clicked_add(my_list2_clear, li) 246 bt.callback_clicked_add(my_list2_clear, li)
238 bt.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) 247 bt.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
@@ -248,58 +257,58 @@ def list2_clicked(obj, item=None):
248 257
249 258
250def list3_clicked(obj, item=None): 259def list3_clicked(obj, item=None):
251 win = elementary.Window("list-3", elementary.ELM_WIN_BASIC) 260 win = Window("list-3", elementary.ELM_WIN_BASIC)
252 win.title_set("List 3") 261 win.title_set("List 3")
253 win.autodel_set(True) 262 win.autodel_set(True)
254 263
255 bg = elementary.Background(win) 264 bg = Background(win)
256 win.resize_object_add(bg) 265 win.resize_object_add(bg)
257 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 266 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
258 bg.show() 267 bg.show()
259 268
260 li = elementary.List(win) 269 li = List(win)
261 win.resize_object_add(li) 270 win.resize_object_add(li)
262 li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 271 li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
263 li.mode_set(elementary.ELM_LIST_COMPRESS) 272 li.mode_set(elementary.ELM_LIST_COMPRESS)
264 273
265 ic = elementary.Icon(win) 274 ic = Icon(win)
266 ic.file_set('images/logo_small.png') 275 ic.file_set('images/logo_small.png')
267 li.item_append("Hello", ic) 276 li.item_append("Hello", ic)
268 ic = elementary.Icon(win) 277 ic = Icon(win)
269 ic.file_set('images/logo_small.png') 278 ic.file_set('images/logo_small.png')
270 ic.resizable_set(0, 0) 279 ic.resizable_set(0, 0)
271 li.item_append("world", ic) 280 li.item_append("world", ic)
272 ic = elementary.Icon(win) 281 ic = Icon(win)
273 ic.standard_set("edit") 282 ic.standard_set("edit")
274 ic.resizable_set(0, 0) 283 ic.resizable_set(0, 0)
275 li.item_append(".", ic) 284 li.item_append(".", ic)
276 285
277 ic = elementary.Icon(win) 286 ic = Icon(win)
278 ic.standard_set("delete") 287 ic.standard_set("delete")
279 ic.resizable_set(0, 0) 288 ic.resizable_set(0, 0)
280 ic2 = elementary.Icon(win) 289 ic2 = Icon(win)
281 ic2.standard_set("clock") 290 ic2.standard_set("clock")
282 ic2.resizable_set(0, 0) 291 ic2.resizable_set(0, 0)
283 it2 = li.item_append("How", ic, ic2) 292 it2 = li.item_append("How", ic, ic2)
284 293
285 bx = elementary.Box(win) 294 bx = Box(win)
286 bx.horizontal_set(True) 295 bx.horizontal_set(True)
287 296
288 ic = elementary.Icon(win) 297 ic = Icon(win)
289 ic.file_set('images/logo_small.png') 298 ic.file_set('images/logo_small.png')
290 ic.resizable_set(0, 0) 299 ic.resizable_set(0, 0)
291 ic.size_hint_align_set(0.5, 0.5) 300 ic.size_hint_align_set(0.5, 0.5)
292 bx.pack_end(ic) 301 bx.pack_end(ic)
293 ic.show() 302 ic.show()
294 303
295 ic = elementary.Icon(win) 304 ic = Icon(win)
296 ic.file_set('images/logo_small.png') 305 ic.file_set('images/logo_small.png')
297 ic.resizable_set(0, 0) 306 ic.resizable_set(0, 0)
298 ic.size_hint_align_set(0.5, 0.0) 307 ic.size_hint_align_set(0.5, 0.0)
299 bx.pack_end(ic) 308 bx.pack_end(ic)
300 ic.show() 309 ic.show()
301 310
302 ic = elementary.Icon(win) 311 ic = Icon(win)
303 ic.file_set('images/logo_small.png') 312 ic.file_set('images/logo_small.png')
304 ic.resizable_set(0, 0) 313 ic.resizable_set(0, 0)
305 ic.size_hint_align_set(0.0, evas.EVAS_HINT_EXPAND) 314 ic.size_hint_align_set(0.0, evas.EVAS_HINT_EXPAND)
@@ -334,26 +343,26 @@ if __name__ == "__main__":
334 elementary.exit() 343 elementary.exit()
335 344
336 elementary.init() 345 elementary.init()
337 win = elementary.Window("test", elementary.ELM_WIN_BASIC) 346 win = Window("test", elementary.ELM_WIN_BASIC)
338 win.title_set("python-elementary test application") 347 win.title_set("python-elementary test application")
339 win.callback_delete_request_add(destroy) 348 win.callback_delete_request_add(destroy)
340 349
341 bg = elementary.Background(win) 350 bg = Background(win)
342 win.resize_object_add(bg) 351 win.resize_object_add(bg)
343 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 352 bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
344 bg.show() 353 bg.show()
345 354
346 box0 = elementary.Box(win) 355 box0 = Box(win)
347 box0.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 356 box0.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
348 win.resize_object_add(box0) 357 win.resize_object_add(box0)
349 box0.show() 358 box0.show()
350 359
351 fr = elementary.Frame(win) 360 fr = Frame(win)
352 fr.text_set("Information") 361 fr.text_set("Information")
353 box0.pack_end(fr) 362 box0.pack_end(fr)
354 fr.show() 363 fr.show()
355 364
356 lb = elementary.Label(win) 365 lb = Label(win)
357 lb.text_set("Please select a test from the list below<br>" 366 lb.text_set("Please select a test from the list below<br>"
358 "by clicking the test button to show the<br>" 367 "by clicking the test button to show the<br>"
359 "test window.") 368 "test window.")
@@ -364,7 +373,7 @@ if __name__ == "__main__":
364 ("List 2", list2_clicked), 373 ("List 2", list2_clicked),
365 ("List 3", list3_clicked)] 374 ("List 3", list3_clicked)]
366 375
367 li = elementary.List(win) 376 li = List(win)
368 li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) 377 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) 378 li.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
370 box0.pack_end(li) 379 box0.pack_end(li)