aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2015-04-15 00:15:59 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2015-04-15 00:17:24 +0300
commit278fe321107aa6d37e9a14ec957ed2360e09a69f (patch)
tree6211afafc0bb4d23bae2eb5d8d0a5597151edec6 /examples/elementary
parentElm: Handle init and shutdown inside the module (diff)
downloadpython-efl-278fe321107aa6d37e9a14ec957ed2360e09a69f.tar.gz
Elm: Add ecore events defined in elm_general.h
Diffstat (limited to 'examples/elementary')
-rwxr-xr-xexamples/elementary/test.py2
-rw-r--r--examples/elementary/test_core_ecore_events_in_elm.py85
2 files changed, 87 insertions, 0 deletions
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index 4f9bb19..eebfc0f 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -38,6 +38,8 @@ elog.setLevel(logging.DEBUG)
items = [
("Core Libs", [
+ ("Ecore Events In Elm", "test_core_ecore_events_in_elm",
+ "core_ecore_events_in_elm_clicked"),
("Evas Objects", "test_core_evas_objects", "core_evas_objects_clicked"),
("Evas Canvas Callbacks", "test_core_evas_canvas_callbacks",
"core_evas_canvas_callbacks_clicked"),
diff --git a/examples/elementary/test_core_ecore_events_in_elm.py b/examples/elementary/test_core_ecore_events_in_elm.py
new file mode 100644
index 0000000..10a90a0
--- /dev/null
+++ b/examples/elementary/test_core_ecore_events_in_elm.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+from __future__ import print_function
+
+from efl.evas import EXPAND_BOTH, FILL_BOTH
+
+from efl import elementary
+from efl.elementary.window import StandardWindow
+from efl.elementary.box import Box
+from efl.elementary.button import Button
+from efl.elementary.notify import Notify
+from efl.elementary.label import Label
+from efl.elementary.general import policy_get, policy_set, on_policy_changed, \
+ ELM_POLICY_QUIT, ELM_POLICY_EXIT, ELM_POLICY_THROTTLE, ELM_POLICY_LAST, \
+ ELM_POLICY_QUIT_NONE, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
+
+win = None
+
+
+policy_mapping = {
+ ELM_POLICY_QUIT: "ELM_POLICY_QUIT",
+ ELM_POLICY_EXIT: "ELM_POLICY_EXIT",
+ ELM_POLICY_THROTTLE: "ELM_POLICY_THROTTLE",
+ ELM_POLICY_LAST: "ELM_POLICY_LAST"
+}
+
+policy_quit_value_mapping = {
+ ELM_POLICY_QUIT_NONE: "ELM_POLICY_QUIT_NONE",
+ ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: "ELM_POLICY_QUIT_LAST_WINDOW_CLOSED"
+}
+
+
+@on_policy_changed
+def policy_changed(ev):
+ text = "policy changed: %s<br>new value: %s<br>old value: %s" % (
+ policy_mapping[ev.policy],
+ policy_quit_value_mapping[ev.new_value],
+ policy_quit_value_mapping[ev.old_value])
+ n = Notify(win, timeout=5)
+ l = Label(n, text=text)
+ n.content = l
+ l.show()
+ n.show()
+
+
+def core_ecore_events_in_elm_clicked(obj, item=None):
+ global win
+ win = StandardWindow(
+ "ecoreevents", "Ecore events in Elm", autodel=True,
+ size=(480, 240))
+ if obj is None:
+ win.callback_delete_request_add(lambda o: elementary.exit())
+
+ hbox = Box(
+ win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
+ horizontal=True)
+ win.resize_object_add(hbox)
+ hbox.show()
+
+ b = Button(win, text="change quit policy", size_hint_align=(0.5, 1.0))
+ hbox.pack_end(b)
+
+ def policy_change(btn):
+ old_value = bool(policy_get(ELM_POLICY_QUIT))
+ new_value = not old_value
+ policy_set(ELM_POLICY_QUIT, new_value)
+ print("changing policy: %s\nnew value: %s\nold value: %s" % (
+ "ELM_POLICY_QUIT",
+ policy_quit_value_mapping[new_value],
+ policy_quit_value_mapping[old_value]))
+
+ b.callback_clicked_add(policy_change)
+ b.show()
+
+ win.show()
+
+
+if __name__ == "__main__":
+ elementary.init()
+
+ core_ecore_events_in_elm_clicked(None)
+
+ elementary.run()
+ elementary.shutdown()