aboutsummaryrefslogtreecommitdiffstats
path: root/tests/elementary/test_colorselector.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_colorselector.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_colorselector.py')
-rw-r--r--tests/elementary/test_colorselector.py134
1 files changed, 134 insertions, 0 deletions
diff --git a/tests/elementary/test_colorselector.py b/tests/elementary/test_colorselector.py
new file mode 100644
index 0000000..9d0c79b
--- /dev/null
+++ b/tests/elementary/test_colorselector.py
@@ -0,0 +1,134 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+from efl import elementary
+from efl import evas
+
+
+def cb_cs_changed(cs, rect):
+ print("changed")
+ (r, g, b, a) = cs.color
+ r = (r * a) / 255
+ g = (g * a) / 255
+ b = (b * a) / 255
+ rect.color = (r, g, b, a)
+
+def cb_cs_item_sel(cs, item, rect):
+ print("selected")
+ (r, g, b, a) = item.color
+ r = (r * a) / 255
+ g = (g * a) / 255
+ b = (b * a) / 255
+ rect.color = (r, g, b, a)
+
+def cb_cs_item_lp(cs, item, rect):
+ print("longpressed")
+ (r, g, b, a) = item.color
+ r = (r * a) / 255
+ g = (g * a) / 255
+ b = (b * a) / 255
+ rect.color = (r, g, b, a)
+
+def colorselector_clicked(obj):
+ win = elementary.Window("colorselector", elementary.ELM_WIN_BASIC)
+ win.title = "ColorSelector test"
+ win.autodel = True
+ if obj is None:
+ win.callback_delete_request_add(lambda o: elementary.exit())
+
+ bg = elementary.Background(win)
+ win.resize_object_add(bg)
+ bg.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ bg.show()
+
+ vbox = elementary.Box(win)
+ vbox.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ win.resize_object_add(vbox)
+ vbox.show()
+
+ fr = elementary.Frame(win)
+ fr.text = "Color View"
+ fr.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
+ fr.size_hint_align = (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
+ vbox.pack_end(fr)
+ fr.show()
+
+ re = evas.Rectangle(win.evas)
+ re.size_hint_min = (1, 100)
+ fr.content = re
+ re.show()
+
+ fr = elementary.Frame(win)
+ fr.text = "Color Selector"
+ fr.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ fr.size_hint_align = (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
+ vbox.pack_end(fr)
+ fr.show()
+
+ cs = elementary.Colorselector(win)
+ cs.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ cs.size_hint_align = (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
+ cs.callback_changed_add(cb_cs_changed, re)
+ cs.callback_color_item_selected_add(cb_cs_item_sel, re)
+ cs.callback_color_item_longpressed_add(cb_cs_item_lp, re)
+ cs.color = (255, 160, 132, 255)
+ fr.content = cs
+ cs.show()
+
+ re.color = cs.color
+ cs.palette_color_add(255, 90, 18, 255)
+ cs.palette_color_add(255, 213, 0, 255)
+ cs.palette_color_add(146, 255, 11, 255)
+ cs.palette_color_add(9, 186, 10, 255)
+ cs.palette_color_add(86, 201, 242, 255)
+ cs.palette_color_add(18, 83, 128, 255)
+ cs.palette_color_add(140, 53, 238, 255)
+ cs.palette_color_add(255, 145, 145, 255)
+ cs.palette_color_add(255, 59, 119, 255)
+ cs.palette_color_add(133, 100, 69, 255)
+ cs.palette_color_add(255, 255, 119, 255)
+ cs.palette_color_add(133, 100, 255, 255)
+
+ hbox = elementary.Box(win)
+ hbox.horizontal = True
+ hbox.size_hint_align = (evas.EVAS_HINT_FILL, 0.0)
+ hbox.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
+ vbox.pack_end(hbox)
+ hbox.show()
+
+ bt = elementary.Button(win)
+ bt.text = "Palette"
+ bt.size_hint_align = (evas.EVAS_HINT_FILL, 0.0)
+ bt.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
+ bt.callback_clicked_add(lambda btn: cs.mode_set(elementary.ELM_COLORSELECTOR_PALETTE))
+ hbox.pack_end(bt)
+ bt.show()
+
+ bt = elementary.Button(win)
+ bt.text = "Components"
+ bt.size_hint_align = (evas.EVAS_HINT_FILL, 0.0)
+ bt.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
+ bt.callback_clicked_add(lambda btn: cs.mode_set(elementary.ELM_COLORSELECTOR_COMPONENTS))
+ hbox.pack_end(bt)
+ bt.show()
+
+ bt = elementary.Button(win)
+ bt.text = "Both"
+ bt.size_hint_align = (evas.EVAS_HINT_FILL, 0.0)
+ bt.size_hint_weight = (evas.EVAS_HINT_EXPAND, 0.0)
+ bt.callback_clicked_add(lambda btn: cs.mode_set(elementary.ELM_COLORSELECTOR_BOTH))
+ hbox.pack_end(bt)
+ bt.show()
+
+ win.resize(320, 550)
+ win.show()
+
+
+if __name__ == "__main__":
+ elementary.init()
+
+ colorselector_clicked(None)
+
+ elementary.run()
+ elementary.shutdown()
+