aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-02-26 09:43:15 +0100
committerDave Andreoli <dave@gurumeditation.it>2017-02-26 09:43:15 +0100
commit6f92607ba4dd1f1fc922fa23daf7adea781a3cfa (patch)
treeb34f6e615ecd9b18214c4f87452b4d4235d9058e
parentNew 1.19 API: elm.Win.stack_* (diff)
downloadpython-efl-6f92607ba4dd1f1fc922fa23daf7adea781a3cfa.tar.gz
New 1.19 API: elm.Panel "toggled" signal
with test
-rw-r--r--doc/elementary/panel.rst5
-rw-r--r--efl/elementary/panel.pxi10
-rw-r--r--examples/elementary/test_panel.py26
3 files changed, 39 insertions, 2 deletions
diff --git a/doc/elementary/panel.rst b/doc/elementary/panel.rst
index 3c2da1e..d3629ad 100644
--- a/doc/elementary/panel.rst
+++ b/doc/elementary/panel.rst
@@ -14,6 +14,11 @@ A panel is a type of animated container that contains subobjects.
It can be expanded or contracted by clicking the button on it's edge.
+Emitted signals
+===============
+
+- ``toggled`` - Emitted when the panel has been toggled. (since 1.19)
+
Layout content parts
====================
diff --git a/efl/elementary/panel.pxi b/efl/elementary/panel.pxi
index cbaf47b..ab65b61 100644
--- a/efl/elementary/panel.pxi
+++ b/efl/elementary/panel.pxi
@@ -118,5 +118,15 @@ cdef class Panel(LayoutClass):
"""Toggle the hidden state of the panel from code."""
elm_panel_toggle(self.obj)
+ def callback_toggled_add(self, func, *args, **kwargs):
+ """ The panel has been toggled.
+
+ .. versionadded:: 1.19
+
+ """
+ self._callback_add("toggled", func, args, kwargs)
+
+ def callback_toggled_del(self, func):
+ self._callback_del("toggled", func)
_object_mapping_register("Elm.Panel", Panel)
diff --git a/examples/elementary/test_panel.py b/examples/elementary/test_panel.py
index cba098c..87e886e 100644
--- a/examples/elementary/test_panel.py
+++ b/examples/elementary/test_panel.py
@@ -21,6 +21,20 @@ from efl.elementary.toolbar import Toolbar, ELM_TOOLBAR_SHRINK_NONE
script_path = os.path.dirname(os.path.abspath(__file__))
img_file = os.path.join(script_path, "images", "plant_01.jpg")
+
+def toolbar_item_clicked_cb(toolbar, item, win):
+ p = win.data["panel1"]
+ print("The top panel is currently %s" % ("hidden" if p.hidden else "shown"))
+ p = win.data["panel2"]
+ print("The left panel is currently %s" % ("hidden" if p.hidden else "shown"))
+ p = win.data["panel3"]
+ print("The right panel is currently %s" % ("hidden" if p.hidden else "shown"))
+ p = win.data["panel4"]
+ print("The bottom panel is currently %s" % ("hidden" if p.hidden else "shown"))
+
+def panel_toggled_cb(panel):
+ print("Panel toggled")
+
def panel_clicked(obj):
win = StandardWindow("panel", "Panel test", autodel=True, size=(320, 400))
if obj is None:
@@ -33,12 +47,14 @@ def panel_clicked(obj):
# top panel (toolbar content)
panel1 = Panel(bx, orient=ELM_PANEL_ORIENT_TOP,
size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+ panel1.callback_toggled_add(panel_toggled_cb)
bx.pack_end(panel1)
panel1.show()
+ win.data['panel1'] = panel1
toolbar = Toolbar(panel1, homogeneous=False,
shrink_mode=ELM_TOOLBAR_SHRINK_NONE)
- toolbar.item_append("user-home", "Hello Toolbar")
+ toolbar.item_append("user-home", "Hello", toolbar_item_clicked_cb, win)
panel1.content = toolbar
toolbar.show()
@@ -55,6 +71,7 @@ def panel_clicked(obj):
# left panel (list content)
panel2 = Panel(table, orient=ELM_PANEL_ORIENT_LEFT,
size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+ panel2.callback_toggled_add(panel_toggled_cb)
table.pack(panel2, 0, 0, 2, 4)
panel2.show()
@@ -64,12 +81,15 @@ def panel_clicked(obj):
li.item_append("Item #%d" % i, ic)
panel2.content = li
li.show()
+ win.data['panel2'] = panel2
# right panel (button content)
panel3 = Panel(table, orient=ELM_PANEL_ORIENT_RIGHT, hidden=True,
size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+ panel3.callback_toggled_add(panel_toggled_cb)
table.pack(panel3, 2, 0, 2, 4);
panel3.show()
+ win.data['panel3'] = panel3
bt = Button(panel3, text="HIDE ME :)", size_hint_weight=EXPAND_BOTH,
size_hint_align=FILL_BOTH)
@@ -80,13 +100,15 @@ def panel_clicked(obj):
# bottom panel (toolbar content)
panel4 = Panel(table, orient=ELM_PANEL_ORIENT_BOTTOM, hidden=True,
size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+ panel4.callback_toggled_add(panel_toggled_cb)
table.pack(panel4, 0, 4, 4, 1)
panel4.show()
+ win.data['panel4'] = panel4
toolbar = Toolbar(panel4, homogeneous=False,
shrink_mode=ELM_TOOLBAR_SHRINK_NONE,
size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
- toolbar.item_append("user-home", "Hello Toolbar")
+ toolbar.item_append(None, "Hello", toolbar_item_clicked_cb, win)
panel4.content = toolbar
toolbar.show()