aboutsummaryrefslogtreecommitdiffstats
path: root/tests/elementary/test_external.py
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2013-02-11 22:32:50 +0000
committerDavide Andreoli <dave@gurumeditation.it>2013-02-11 22:32:50 +0000
commit8b8639886059814a36f57164d5572e97bcb00a47 (patch)
tree1c5a170de002793c1402d6afcc16c63115d81caa /tests/elementary/test_external.py
downloadpython-efl-8b8639886059814a36f57164d5572e97bcb00a47.tar.gz
Put in a first, still wip, version of the python bindings in a merged tree.
This is meant to be the 1.8 version of the wrappers and will include everything that now is in the python folder. Atm this include evas, ecore, edje, elementary and emotion (emotion still commented in the build couse it need some more testing). Eo is used as a base for all the objects that inherit from it in C, but in real nothing is used from Eo, it is used more like a container to share code between the libs. All the docs has been stripped out because we want to use the new sphinx style docs that Kay has done in his git repo. (Kay: please wait a little bit to include it, as working on the libs without docs is much more easy) The new wrappers include a new container module called efl and thus you can live with both the old and the new installation. This also means that you need to import the new modules as: "from efl import evas" (instead of the old "import evas") The idea here is that you can make your code works with both version doing something like: try: import evas except: from efl import evas ...like is done in the gtk bindings Some stuff has been leaved out on purpose, because was old stuff (like the hacked evas rotation stuff) or because was not working as expected (like all the ecore.evas.XXX modules). See the TODO.txt file for more info. Probably some stuff is out just because I missed them, let me know if you miss something. Improvements from the old version: - Py3 compatible (still some work to be done, but really only TODO, no problems to resolv) - Should also works on other platforms, like windoz (but not tested) - Unittests greatly improved, you can also run ALL tests at once - much more simpler :) I will contine the works in the next weeks and hope someone will help too. NOTE: I switched back to setup.py instead of autotools, because that is the right way to compile python stuff. So to build just use: python setup.py install or python3 setup.py install Enjoy davemds SVN revision: 83831
Diffstat (limited to 'tests/elementary/test_external.py')
-rw-r--r--tests/elementary/test_external.py177
1 files changed, 177 insertions, 0 deletions
diff --git a/tests/elementary/test_external.py b/tests/elementary/test_external.py
new file mode 100644
index 0000000..a3980f5
--- /dev/null
+++ b/tests/elementary/test_external.py
@@ -0,0 +1,177 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+from efl import elementary
+from efl import evas
+
+
+
+def edje_external_button_clicked(obj, item=None):
+ win = elementary.Window("edje-external-button", elementary.ELM_WIN_BASIC)
+ win.title_set("Edje External Button")
+ win.autodel_set(True)
+ if obj is None:
+ win.callback_delete_request_add(lambda o: elementary.exit())
+
+ ly = elementary.Layout(win)
+ ly.file_set("test_external.edj", "external/button")
+ ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ win.resize_object_add(ly)
+ ly.show()
+
+ win.resize(320, 400)
+ win.show()
+
+
+def animate(ly):
+ val = ly.edje_get().part_external_object_get("ext_pbar1").value
+ val += 0.0123
+
+ for part_name in ["ext_pbar1", "ext_pbar3", "ext_pbar4", "ext_pbar6"]:
+ ly.edje_get().part_external_object_get(part_name).value = val
+
+ if val < 1:
+ ecore.timer_add(0.1, animate, ly)
+ else:
+ for part_name in ["ext_pbar2", "ext_pbar5", "ext_pbar7"]:
+ ly.edje_get().part_external_object_get(part_name).pulse(False)
+ for part_name in ["ext_button1", "ext_button2", "ext_button3"]:
+ ly.edje_get().part_external_object_get(part_name).disabled = False
+
+ return False
+
+def cb_btn3_clicked(bt, ly):
+ ly.edje_get().part_external_object_get("ext_pbar1").value = 0.0
+
+ for part_name in ["ext_pbar2", "ext_pbar5", "ext_pbar7"]:
+ ly.edje_get().part_external_object_get(part_name).pulse(True)
+ for part_name in ["ext_button1", "ext_button2", "ext_button3"]:
+ ly.edje_get().part_external_object_get(part_name).disabled = True
+
+ ecore.timer_add(0.1, animate, ly)
+
+def edje_external_pbar_clicked(obj, item=None):
+ win = elementary.Window("edje-external-pbar", elementary.ELM_WIN_BASIC)
+ win.title_set("Edje External Progress Bar")
+ win.autodel_set(True)
+ if obj is None:
+ win.callback_delete_request_add(lambda o: elementary.exit())
+
+ ly = elementary.Layout(win)
+ ly.file_set("test_external.edj", "external/pbar")
+ ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ win.resize_object_add(ly)
+ ly.show()
+
+ bt = ly.edje_get().part_external_object_get("ext_button3")
+ bt.text = "...or Pyton"
+ bt.callback_clicked_add(cb_btn3_clicked, ly)
+
+ win.resize(320, 400)
+ win.show()
+
+
+def edje_external_scroller_clicked(obj, item=None):
+ win = elementary.Window("edje-external-scroller", elementary.ELM_WIN_BASIC)
+ win.title_set("Edje External Scroller")
+ win.autodel_set(True)
+ if obj is None:
+ win.callback_delete_request_add(lambda o: elementary.exit())
+
+ ly = elementary.Layout(win)
+ ly.file_set("test_external.edj", "external/scroller")
+ ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ win.resize_object_add(ly)
+ ly.show()
+
+ win.resize(320, 400)
+ win.show()
+
+
+def edje_external_slider_clicked(obj, item=None):
+ win = elementary.Window("edje-external-slider", elementary.ELM_WIN_BASIC)
+ win.title_set("Edje External Slider")
+ win.autodel_set(True)
+ if obj is None:
+ win.callback_delete_request_add(lambda o: elementary.exit())
+
+ ly = elementary.Layout(win)
+ ly.file_set("test_external.edj", "external/slider")
+ ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ win.resize_object_add(ly)
+ ly.show()
+
+ win.resize(320, 400)
+ win.show()
+
+
+def edje_external_video_clicked(obj, item=None):
+ win = elementary.Window("edje-external-video", elementary.ELM_WIN_BASIC)
+ win.title_set("Edje External Video")
+ win.autodel_set(True)
+ if obj is None:
+ win.callback_delete_request_add(lambda o: elementary.exit())
+
+ ly = elementary.Layout(win)
+ ly.file_set("test_external.edj", "external/video")
+ ly.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ win.resize_object_add(ly)
+ ly.show()
+
+ win.resize(320, 400)
+ win.show()
+
+
+
+if __name__ == "__main__":
+ def destroy(obj):
+ elementary.exit()
+
+ elementary.init()
+ win = elementary.Window("test", elementary.ELM_WIN_BASIC)
+ win.title_set("python-elementary test application")
+ win.callback_delete_request_add(destroy)
+
+ bg = elementary.Background(win)
+ win.resize_object_add(bg)
+ bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ bg.show()
+
+ box0 = elementary.Box(win)
+ box0.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ win.resize_object_add(box0)
+ box0.show()
+
+ fr = elementary.Frame(win)
+ fr.text_set("Information")
+ box0.pack_end(fr)
+ fr.show()
+
+ lb = elementary.Label(win)
+ lb.text_set("Please select a test from the list below<br>"
+ "by clicking the test button to show the<br>"
+ "test window.")
+ fr.content_set(lb)
+ lb.show()
+
+ items = [("Ext Button", edje_external_button_clicked),
+ ("Ext ProgressBar", edje_external_pbar_clicked),
+ ("Ext Scroller", edje_external_scroller_clicked),
+ ("Ext Slider", edje_external_slider_clicked),
+ ("Ext Video", edje_external_video_clicked)]
+
+ li = elementary.List(win)
+ li.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ li.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
+ box0.pack_end(li)
+ li.show()
+
+ for item in items:
+ li.item_append(item[0], callback=item[1])
+
+ li.go()
+
+ win.resize(320,520)
+ win.show()
+ elementary.run()
+ elementary.shutdown()