aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test_flipselector.py
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2013-02-15 20:41:55 +0000
committerDavide Andreoli <dave@gurumeditation.it>2013-02-15 20:41:55 +0000
commitb58be93f121c2ca240b888d1dd41896d4779927f (patch)
tree371d4e331b3e685e106b211ce3e28b31e9886ada /examples/elementary/test_flipselector.py
parentPython-EFL: Cleanup and enable compilation of emotion, cleaned also the test. (diff)
downloadpython-efl-b58be93f121c2ca240b888d1dd41896d4779927f.tar.gz
move elementary and emotion tests in a new examples dir. Now tests/ contain only unittest while examples/ all the other tests that need user interaction
SVN revision: 83964
Diffstat (limited to 'examples/elementary/test_flipselector.py')
-rw-r--r--examples/elementary/test_flipselector.py136
1 files changed, 136 insertions, 0 deletions
diff --git a/examples/elementary/test_flipselector.py b/examples/elementary/test_flipselector.py
new file mode 100644
index 0000000..6fdec19
--- /dev/null
+++ b/examples/elementary/test_flipselector.py
@@ -0,0 +1,136 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+from efl import elementary
+from efl import evas
+
+
+def sel_cb(fp, *args):
+ if args:
+ print("label of selected item is: %s\n" % args[0].text)
+
+def unsel_cb(bt, fp):
+ fp.selected_item.selected = False
+
+def last_cb(bt, fp):
+ fp.last_item.selected = True
+
+def third_from_end_cb(bt, fp):
+ fp.last_item.prev.prev.selected = True
+
+def underflow_cb(fp):
+ print("underflow!\n")
+
+def overflow_cb(fp):
+ print("overflow!\n")
+
+def slider_change_cb(sl, fp):
+ fp.first_interval = sl.value
+
+def flip_next_cb(bt, fp):
+ fp.next()
+
+def flip_prev_cb(bt, fp):
+ fp.prev()
+
+def flipselector_clicked(obj):
+ lbl = (
+ "Elementary",
+ "Evas",
+ "Eina",
+ "Edje",
+ "Eet",
+ "Ecore",
+ "Efreet",
+ "Edbus"
+ )
+
+ win = elementary.StandardWindow("flipselector", "Flip Selector")
+ win.autodel = True
+
+ bx = elementary.Box(win)
+ bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ win.resize_object_add(bx)
+ bx.show()
+
+ fp = elementary.FlipSelector(win)
+ fp.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ fp.callback_selected_add(sel_cb)
+ fp.callback_underflowed_add(overflow_cb)
+ fp.callback_overflowed_add(underflow_cb)
+ for i in range(0, len(lbl)):
+ it = fp.item_append(lbl[i])
+ if (i == 3):
+ edje_it = it
+ edje_it.selected = True
+ bx.pack_end(fp)
+ fp.show()
+
+ bx2 = elementary.Box(win)
+ bx2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ bx2.horizontal = True
+ bx.pack_end(bx2)
+ bx2.show()
+
+ fp = elementary.FlipSelector(win)
+ fp.callback_underflowed_add(overflow_cb)
+ fp.callback_overflowed_add(underflow_cb)
+ fp.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ for i in range(1990, 2100):
+ fp.item_append(str(i), sel_cb)
+
+ bt = elementary.Button(win)
+ bt.text = "Flip Prev"
+ bt.callback_clicked_add(flip_prev_cb, fp)
+
+ bx2.pack_end(bt)
+ bt.show()
+
+ bx2.pack_end(fp)
+ fp.show()
+
+ bt = elementary.Button(win)
+ bt.text = "Flip Next"
+ bt.callback_clicked_add(flip_next_cb, fp)
+ bx2.pack_end(bt)
+ bt.show()
+
+ sl = elementary.Slider(win)
+ sl.text = "Flip Iterval:"
+ sl.unit_format = "%1.2f"
+ sl.min_max = (0.0, 3.0)
+ sl.value = (0.85)
+ sl.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
+ sl.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ bx.pack_end(sl)
+ sl.show()
+ sl.callback_changed_add(slider_change_cb, fp)
+
+ bt = elementary.Button(win)
+ bt.text = "Select Last"
+ bt.callback_clicked_add(last_cb, fp)
+ bx.pack_end(bt)
+ bt.show()
+
+ bt = elementary.Button(win)
+ bt.text = "Select 2097"
+ bt.callback_clicked_add(third_from_end_cb, fp)
+ bx.pack_end(bt)
+ bt.show()
+
+ bt = elementary.Button(win)
+ bt.text = "Unselect year"
+ bt.callback_clicked_add(unsel_cb, fp)
+ bx.pack_end(bt)
+ bt.show()
+
+ win.show()
+
+
+if __name__ == "__main__":
+ elementary.init()
+
+ flipselector_clicked(None)
+
+ elementary.run()
+ elementary.shutdown()