summaryrefslogtreecommitdiff
path: root/examples/elementary/test_floating.py
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2013-04-14 20:37:20 +0000
committerKai Huuhko <kai.huuhko@gmail.com>2013-04-22 20:12:28 +0300
commit0ed61d0b6c9ccbc3add59fb70b7c24e9bb587e9e (patch)
tree90482bd39c89e2f34f28b0aa98312016df84b0b2 /examples/elementary/test_floating.py
parentaa1828d6688658fa90ea13b19a8009ea28456bad (diff)
Elementary: Add a simple test for floating objects.
Diffstat (limited to 'examples/elementary/test_floating.py')
-rw-r--r--examples/elementary/test_floating.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/examples/elementary/test_floating.py b/examples/elementary/test_floating.py
new file mode 100644
index 0000000..3def0ea
--- /dev/null
+++ b/examples/elementary/test_floating.py
@@ -0,0 +1,65 @@
1from math import sin
2
3from efl import elementary
4from efl.elementary.window import StandardWindow
5from efl.elementary.genlist import Genlist, GenlistItem, GenlistItemClass, \
6 ELM_GENLIST_ITEM_NONE
7from efl.elementary.icon import Icon
8from efl.ecore import Animator, loop_time_get
9from efl.evas import EVAS_ASPECT_CONTROL_VERTICAL, EVAS_HINT_EXPAND, \
10 EVAS_HINT_FILL
11
12class ItemClass(GenlistItemClass):
13 def text_get(self, obj, part, *args, **kwargs):
14 return "Item #{0}".format(args[0])
15
16 def content_get(self, obj, part, *args, **kwargs):
17 ic = Icon(obj)
18 ic.file = "images/logo_small.png"
19 ic.size_hint_aspect = EVAS_ASPECT_CONTROL_VERTICAL, 1, 1
20 return ic
21
22def gl_sel_cb(obj, event_info, *args):
23 print("sel item data [{0}] on genlist obj [{1}], item [{2}]".format(data, obj, event_info))
24
25def anim(*args, **kwargs):
26 gl = args[0]
27 y = 0
28 x = (sin(loop_time_get()) * 500)
29 gl.move(x, y)
30
31 return True
32
33def del_cb(obj, *args, **kwargs):
34 ani = args[0]
35 ani.delete()
36
37def floating_clicked(obj):
38 win = StandardWindow("floating", "Floating")
39 win.autodel = True
40
41 gl = Genlist(win)
42 gl.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
43 gl.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL
44 gl.move(800, 0)
45 gl.size = 480, 800
46 gl.show()
47
48 for i in range(20):
49 GenlistItem(ItemClass(), None, ELM_GENLIST_ITEM_NONE, gl_sel_cb, i).append_to(gl)
50
51 win.size = 480, 800
52 win.show()
53
54 ani = Animator(anim, gl)
55 win.callback_delete_request_add(del_cb, ani)
56 if obj is None:
57 win.callback_delete_request_add(lambda o: elementary.exit())
58
59if __name__ == "__main__":
60 elementary.init()
61
62 floating_clicked(None)
63
64 elementary.run()
65 elementary.shutdown()