summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2016-11-05 15:14:41 +0100
committerDave Andreoli <dave@gurumeditation.it>2016-11-05 15:14:41 +0100
commitf2f8906968bf85805ae9a44512b6dcf48021d8c0 (patch)
treee5dd44a3e5f4edfb958addb27546970092defb03
parent032750af771a70c2100bf6fc2bb9dc29ab7af2fd (diff)
Respect pep8
-rw-r--r--examples/elementary/test_gengrid.py51
1 files changed, 30 insertions, 21 deletions
diff --git a/examples/elementary/test_gengrid.py b/examples/elementary/test_gengrid.py
index 0d879d8..239ef1a 100644
--- a/examples/elementary/test_gengrid.py
+++ b/examples/elementary/test_gengrid.py
@@ -15,40 +15,48 @@ from efl.elementary import StandardWindow, Button, Check, Entry, Image, \
15script_path = os.path.dirname(os.path.abspath(__file__)) 15script_path = os.path.dirname(os.path.abspath(__file__))
16img_path = os.path.join(script_path, "images") 16img_path = os.path.join(script_path, "images")
17 17
18
18class ScrollableGengrid(Scrollable, Gengrid): 19class ScrollableGengrid(Scrollable, Gengrid):
19 def __init__(self, canvas, *args, **kwargs): 20 def __init__(self, canvas, *args, **kwargs):
20 Gengrid.__init__(self, canvas, *args, **kwargs) 21 Gengrid.__init__(self, canvas, *args, **kwargs)
21 22
22 23
23images = ["panel_01.jpg", "plant_01.jpg", "rock_01.jpg", "rock_02.jpg", 24images = ["panel_01.jpg", "plant_01.jpg", "rock_01.jpg", "rock_02.jpg",
24 "sky_01.jpg", "sky_02.jpg", "sky_03.jpg", "sky_04.jpg", "wood_01.jpg"] 25 "sky_01.jpg", "sky_02.jpg", "sky_03.jpg", "sky_04.jpg", "wood_01.jpg"]
25 26
26 27
27def gg_text_get(obj, part, item_data): 28def gg_text_get(obj, part, item_data):
28 return "Item # %s" % (item_data) 29 return "Item # %s" % (item_data)
29 30
31
30def gg_content_get(obj, part, data): 32def gg_content_get(obj, part, data):
31 if part == "elm.swallow.icon": 33 if part == "elm.swallow.icon":
32 im = Image(obj, file=os.path.join(img_path, random.choice(images)), 34 im = Image(obj, file=os.path.join(img_path, random.choice(images)),
33 size_hint_aspect=(EVAS_ASPECT_CONTROL_BOTH, 1, 1)) 35 size_hint_aspect=(EVAS_ASPECT_CONTROL_BOTH, 1, 1))
34 return im 36 return im
37
35 return None 38 return None
36 39
40
37def gg_state_get(obj, part, item_data): 41def gg_state_get(obj, part, item_data):
38 return False 42 return False
39 43
44
40def gg_del(obj, item_data): 45def gg_del(obj, item_data):
41 # commented out because this make clear() slow with many items 46 # commented out because this make clear() slow with many items
42 # print "[item del] # %d - %s" % (item_data, obj) 47 # print "[item del] # %d - %s" % (item_data, obj)
43 pass 48 pass
44 49
50
45def gg_sel(gg, ggi, *args, **kwargs): 51def gg_sel(gg, ggi, *args, **kwargs):
46 (x, y) = ggi.pos_get() 52 (x, y) = ggi.pos_get()
47 print(("[item selected] # %d at pos %d %d" % (ggi.data, x, y))) 53 print(("[item selected] # %d at pos %d %d" % (ggi.data, x, y)))
48 54
55
49def gg_unsel(gg, ggi, *args, **kwargs): 56def gg_unsel(gg, ggi, *args, **kwargs):
50 print(("[item unselected] # %d" % (ggi.data))) 57 print(("[item unselected] # %d" % (ggi.data)))
51 58
59
52def gg_clicked_double(gg, ggi, *args, **kwargs): 60def gg_clicked_double(gg, ggi, *args, **kwargs):
53 print(("[item double clicked] # %d" % (ggi.data))) 61 print(("[item double clicked] # %d" % (ggi.data)))
54 62
@@ -56,7 +64,8 @@ def gg_clicked_double(gg, ggi, *args, **kwargs):
56def gengrid_clicked(obj): 64def gengrid_clicked(obj):
57 65
58 global item_count 66 global item_count
59 item_count = 25 67 # item_count = 25
68 item_count = 50
60 69
61 win = StandardWindow("gengrid", "Gengrid", autodel=True, size=(480, 600)) 70 win = StandardWindow("gengrid", "Gengrid", autodel=True, size=(480, 600))
62 if obj is None: 71 if obj is None:
@@ -68,13 +77,14 @@ def gengrid_clicked(obj):
68 77
69 # gengrid 78 # gengrid
70 itc = GengridItemClass(item_style="default", 79 itc = GengridItemClass(item_style="default",
71 text_get_func=gg_text_get, 80 text_get_func=gg_text_get,
72 content_get_func=gg_content_get, 81 content_get_func=gg_content_get,
73 state_get_func=gg_state_get, 82 state_get_func=gg_state_get,
74 del_func=gg_del) 83 del_func=gg_del)
75 gg = ScrollableGengrid(win, size_hint_weight=EXPAND_BOTH, 84 gg = ScrollableGengrid(win, size_hint_weight=EXPAND_BOTH,
76 size_hint_align=FILL_BOTH, horizontal=False, bounce=(False, True), 85 size_hint_align=FILL_BOTH, horizontal=False,
77 item_size=(80, 80), align=(0.5, 0.0)) 86 bounce=(False, True),
87 item_size=(80, 80), align=(0.5, 0.0))
78 tb.pack(gg, 0, 0, 6, 1) 88 tb.pack(gg, 0, 0, 6, 1)
79 gg.callback_selected_add(gg_sel) 89 gg.callback_selected_add(gg_sel)
80 gg.callback_unselected_add(gg_unsel) 90 gg.callback_unselected_add(gg_unsel)
@@ -159,14 +169,14 @@ def gengrid_clicked(obj):
159 print((gg.item_size_get())) 169 print((gg.item_size_get()))
160 170
161 (w, h) = gg.item_size 171 (w, h) = gg.item_size
162 sl = Slider(win, text="ItemSizeW", min_max=(0, 500), 172 sl = Slider(win, text="ItemSizeW", min_max=(0, 500), span_size=100,
163 indicator_format="%.0f", unit_format="%.0f", span_size=100, value=w) 173 indicator_format="%.0f", unit_format="%.0f", value=w)
164 sl.callback_changed_add(item_size_w_changed, gg) 174 sl.callback_changed_add(item_size_w_changed, gg)
165 tb.pack(sl, 0, 2, 2, 1) 175 tb.pack(sl, 0, 2, 2, 1)
166 sl.show() 176 sl.show()
167 177
168 sl = Slider(win, text="ItemSizeH", min_max=(0, 500), 178 sl = Slider(win, text="ItemSizeH", min_max=(0, 500), span_size=100,
169 indicator_format="%.0f", unit_format="%.0f", span_size=100, value=h) 179 indicator_format="%.0f", unit_format="%.0f", value=h)
170 sl.callback_changed_add(item_size_h_changed, gg) 180 sl.callback_changed_add(item_size_h_changed, gg)
171 tb.pack(sl, 0, 3, 2, 1) 181 tb.pack(sl, 0, 3, 2, 1)
172 sl.show() 182 sl.show()
@@ -184,14 +194,14 @@ def gengrid_clicked(obj):
184 194
185 (ax, ay) = gg.align 195 (ax, ay) = gg.align
186 196
187 sl = Slider(win, text="AlignX", min_max=(0.0, 1.0), 197 sl = Slider(win, text="AlignX", min_max=(0.0, 1.0), span_size=100,
188 indicator_format="%.2f", unit_format="%.2f", span_size=100, value=ax) 198 indicator_format="%.2f", unit_format="%.2f", value=ax)
189 sl.callback_changed_add(alignx_changed, gg) 199 sl.callback_changed_add(alignx_changed, gg)
190 tb.pack(sl, 0, 4, 2, 1) 200 tb.pack(sl, 0, 4, 2, 1)
191 sl.show() 201 sl.show()
192 202
193 sl = Slider(win, text="AlignY", min_max=(0.0, 1.0), 203 sl = Slider(win, text="AlignY", min_max=(0.0, 1.0), span_size=100,
194 indicator_format="%.2f", unit_format="%.2f", span_size=100, value=ay) 204 indicator_format="%.2f", unit_format="%.2f", value=ay)
195 sl.callback_changed_add(aligny_changed, gg) 205 sl.callback_changed_add(aligny_changed, gg)
196 tb.pack(sl, 0, 5, 2, 1) 206 tb.pack(sl, 0, 5, 2, 1)
197 sl.show() 207 sl.show()
@@ -320,7 +330,7 @@ def gengrid_clicked(obj):
320 obj.show() 330 obj.show()
321 # Now all the unsetted objects are orphan in the canvas, 331 # Now all the unsetted objects are orphan in the canvas,
322 # the user should do something with them 332 # the user should do something with them
323 333
324 bt = Button(win, size_hint_align=FILL_HORIZ, text="Item content unset") 334 bt = Button(win, size_hint_align=FILL_HORIZ, text="Item content unset")
325 bt.callback_clicked_add(content_unset_clicked, gg) 335 bt.callback_clicked_add(content_unset_clicked, gg)
326 tb.pack(bt, 5, 4, 1, 1) 336 tb.pack(bt, 5, 4, 1, 1)
@@ -389,7 +399,7 @@ def gengrid_clicked(obj):
389 tb.pack(bt, 5, 6, 1, 1) 399 tb.pack(bt, 5, 6, 1, 1)
390 bt.show() 400 bt.show()
391 401
392 bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn selected") 402 bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn sel")
393 bt.callback_clicked_add(bring_in_clicked, gg, rdg, "selected_item") 403 bt.callback_clicked_add(bring_in_clicked, gg, rdg, "selected_item")
394 tb.pack(bt, 4, 7, 2, 1) 404 tb.pack(bt, 4, 7, 2, 1)
395 bt.show() 405 bt.show()
@@ -405,7 +415,7 @@ def gengrid_clicked(obj):
405 en.focus = True 415 en.focus = True
406 elif gg.selected_item: 416 elif gg.selected_item:
407 gg.selected_item.selected = False 417 gg.selected_item.selected = False
408 418
409 lb = Label(win, text="Search:") 419 lb = Label(win, text="Search:")
410 tb.pack(lb, 0, 6, 2, 1) 420 tb.pack(lb, 0, 6, 2, 1)
411 lb.show() 421 lb.show()
@@ -417,7 +427,6 @@ def gengrid_clicked(obj):
417 tb.pack(en, 0, 7, 2, 1) 427 tb.pack(en, 0, 7, 2, 1)
418 en.show() 428 en.show()
419 en.focus = True 429 en.focus = True
420
421 430
422 print(gg) 431 print(gg)
423 432