aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2016-08-09 15:39:35 +0200
committerDave Andreoli <dave@gurumeditation.it>2016-08-09 15:39:35 +0200
commitc11a7cf227d6f07ef8ca166f11fc649037708e1c (patch)
tree1e3d3cbccce905dc758de53cc79307614ad2cae5 /examples/elementary
parentFix implementation of elm.GenlistItem.all_contents_unset() (diff)
downloadpython-efl-c11a7cf227d6f07ef8ca166f11fc649037708e1c.tar.gz
New 1.18 API: elm Genlist reusable content functionality
with a FAILING test (failing also in C) (I love to implement broken stuff)
Diffstat (limited to 'examples/elementary')
-rwxr-xr-xexamples/elementary/test.py1
-rw-r--r--examples/elementary/test_genlist_reusable.py76
2 files changed, 77 insertions, 0 deletions
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index f2e984d..f66f0d3 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -181,6 +181,7 @@ items = [
("Genlist Decorate All Mode", "test_genlist_decorate_all", "test_genlist_decorate_all"),
("Genlist Search by Text", "test_genlist_search", "test_genlist_search"),
("Genlist Reorder Mode", "test_genlist_reorder", "test_genlist_reorder"),
+ ("Genlist Reusable Contents", "test_genlist_reusable", "test_genlist_reusable"),
]),
("Lists - List", [
("List", "test_list", "list_clicked"),
diff --git a/examples/elementary/test_genlist_reusable.py b/examples/elementary/test_genlist_reusable.py
new file mode 100644
index 0000000..8d83904
--- /dev/null
+++ b/examples/elementary/test_genlist_reusable.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+
+from efl.evas import EXPAND_BOTH, EXPAND_HORIZ, FILL_BOTH
+from efl import elementary as elm
+
+
+class MyItemClass(elm.GenlistItemClass):
+ def __init__(self):
+ elm.GenlistItemClass.__init__(self, item_style='default')
+
+ def text_get(self, obj, part, item_data):
+ return 'Item # %i' % item_data
+
+ def content_get(self, obj, part, item_data):
+ if part == 'elm.swallow.icon':
+ return elm.Icon(obj, standard='user-home')
+ if part == 'elm.swallow.end':
+ print('Creating NEW content for item #%d' % item_data)
+ txt = '<warning>Content for item %i</warning>' % item_data
+ return elm.Label(obj, text=txt)
+ return None
+
+ def reusable_content_get(self, obj, part, item_data, old_content):
+ if part == 'elm.swallow.end' and old_content:
+ if obj.data['reusable_enabled'] == True:
+ print('REUSING content for item # %i' % item_data)
+ return old_content
+ return None
+
+itc = MyItemClass()
+
+
+def check_changed_cb(ck, gl):
+ gl.data['reusable_enabled'] = ck.state
+ gl.realized_items_update()
+
+def test_genlist_reusable(parent):
+ win = elm.StandardWindow('GenlistReusable', 'Genlist Reusable Contents',
+ size=(400, 400), autodel=True)
+
+ # main vertical box
+ box = elm.Box(win, size_hint_weight=EXPAND_BOTH)
+ win.resize_object_add(box)
+ box.show()
+
+ # info frame
+ fr = elm.Frame(win, text='Information', size_hint_expand=EXPAND_HORIZ,
+ size_hint_fill=FILL_BOTH)
+ fr.content = elm.Label(fr, text='Numbers on the left should always match the one on the right')
+ box.pack_end(fr)
+ fr.show()
+
+ # genlist
+ gl = elm.Genlist(win, homogeneous=True, mode=elm.ELM_LIST_COMPRESS,
+ size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
+ box.pack_end(gl)
+ for i in range(0, 2000):
+ gl.item_append(itc, i)
+ gl.show()
+ gl.data['reusable_enabled'] = True
+
+ # buttons
+ ck = elm.Check(win, text='Enable reusable contents', state=True)
+ ck.callback_changed_add(check_changed_cb, gl)
+ box.pack_end(ck)
+ ck.show()
+
+ win.show()
+
+
+if __name__ == '__main__':
+ elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
+ test_genlist_reusable(None)
+ elm.run()