davemds pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=28d1e6853eb46b1030078abd9cd5fcd21778a012

commit 28d1e6853eb46b1030078abd9cd5fcd21778a012
Author: Dave Andreoli <[email protected]>
Date:   Sat Jan 17 17:47:58 2015 +0100

    New 1.13 property elm.Table.align
    
    And small improvements to the table test
---
 efl/elementary/table.pxd          |   2 +
 efl/elementary/table.pyx          |  28 +++++++-
 examples/elementary/test.py       |  10 +--
 examples/elementary/test_table.py | 139 +++++++++++++++++++++-----------------
 4 files changed, 111 insertions(+), 68 deletions(-)

diff --git a/efl/elementary/table.pxd b/efl/elementary/table.pxd
index 97c8f9b..8bb0177 100644
--- a/efl/elementary/table.pxd
+++ b/efl/elementary/table.pxd
@@ -6,6 +6,8 @@ cdef extern from "Elementary.h":
     Eina_Bool                elm_table_homogeneous_get(const Evas_Object *obj)
     void                     elm_table_padding_set(Evas_Object *obj, 
Evas_Coord horizontal, Evas_Coord vertical)
     void                     elm_table_padding_get(const Evas_Object *obj, 
Evas_Coord *horizontal, Evas_Coord *vertical)
+    void                     elm_table_align_set(Evas_Object *obj, double 
horizontal, double vertical)
+    void                     elm_table_align_get(const Evas_Object *obj, 
double *horizontal, double *vertical)
     void                     elm_table_pack(Evas_Object *obj, Evas_Object 
*subobj, int x, int y, int w, int h)
     void                     elm_table_unpack(Evas_Object *obj, Evas_Object 
*subobj)
     void                     elm_table_clear(Evas_Object *obj, Eina_Bool clear)
diff --git a/efl/elementary/table.pyx b/efl/elementary/table.pyx
index dc7ad35..60d1a01 100644
--- a/efl/elementary/table.pyx
+++ b/efl/elementary/table.pyx
@@ -84,7 +84,7 @@ cdef class Table(Object):
     property padding:
         """Padding between cells.
 
-        Default value is 0.
+        Default value is (0, 0).
 
         :type: (int, int)
 
@@ -105,6 +105,32 @@ cdef class Table(Object):
         elm_table_padding_get(self.obj, &horizontal, &vertical)
         return (horizontal, vertical)
 
+    property align:
+        """The alignment of the table
+
+        Default value is (0.5, 0.5)
+
+        :type: (double, double)
+
+        .. versionadded:: 1.13
+
+        """
+        def __get__(self):
+            cdef double horizontal, vertical
+            elm_table_align_get(self.obj, &horizontal, &vertical)
+            return (horizontal, vertical)
+
+        def __set__(self, value):
+            horizontal, vertical = value
+            elm_table_align_set(self.obj, horizontal, vertical)
+
+    def align_set(self, horizontal, vertical):
+        elm_table_align_set(self.obj, horizontal, vertical)
+    def align_get(self):
+        cdef double horizontal, vertical
+        elm_table_align_get(self.obj, &horizontal, &vertical)
+        return (horizontal, vertical)
+
     def pack(self, evasObject subobj, x, y, w, h):
         """Add a subobject on the table with the coordinates passed
 
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index 46a110d..858b5b8 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -71,11 +71,11 @@ items = [
         ("Layout", "test_layout", "layout_clicked"),
         ("Table", "test_table", "table_clicked"),
         ("Table Homogeneous", "test_table", "table2_clicked"),
-        ("Table 3", "test_table", "table3_clicked"),
-        ("Table 4", "test_table", "table4_clicked"),
-        ("Table 5", "test_table", "table5_clicked"),
-        ("Table 6", "test_table", "table6_clicked"),
-        ("Table 7", "test_table", "table7_clicked"),
+        ("Table Repack", "test_table", "table3_clicked"),
+        ("Table Repack 2", "test_table", "table4_clicked"),
+        ("Table Percent", "test_table", "table5_clicked"),
+        ("Table Multi", "test_table", "table6_clicked"),
+        ("Table Multi 2", "test_table", "table7_clicked"),
     ]),
     ("Cursors", [
         ("Cursor", "test_cursor", "cursor_clicked"),
diff --git a/examples/elementary/test_table.py 
b/examples/elementary/test_table.py
index 974202b..b4a8e67 100644
--- a/examples/elementary/test_table.py
+++ b/examples/elementary/test_table.py
@@ -14,6 +14,7 @@ from efl.elementary.label import Label
 from efl.elementary.frame import Frame
 
 
+### Table
 def table_clicked(obj, item=None):
     win = StandardWindow("table", "Table", autodel=True)
 
@@ -22,37 +23,39 @@ def table_clicked(obj, item=None):
     tb.show()
 
     bt = Button(win, text="Button 1", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 0, 0, 1, 1)
     bt.show()
 
     bt = Button(win, text="Button 2", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 0, 1, 1)
     bt.show()
 
     bt = Button(win, text="Button 3", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 2, 0, 1, 1)
     bt.show()
 
     bt = Button(win, text="Button 4", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 0, 1, 2, 1)
     bt.show()
 
     bt = Button(win, text="Button 5", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 2, 1, 1, 3)
     bt.show()
 
     bt = Button(win, text="Button 6", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 0, 2, 2, 2)
     bt.show()
 
     win.show()
 
+
+### Table Homogeneous
 def table2_clicked(obj, item=None):
     win = StandardWindow("table2", "Table Homogeneous", autodel=True)
 
@@ -61,214 +64,226 @@ def table2_clicked(obj, item=None):
     tb.show()
 
     bt = Button(win, text="A", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 1, 2, 2)
     bt.show()
 
     bt = Button(win, text="Blah blah blah", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 3, 0, 2, 3)
     bt.show()
 
     bt = Button(win, text="Hallow", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 0, 3, 10, 1)
     bt.show()
 
     bt = Button(win, text="B", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 2, 5, 2, 1)
     bt.show()
 
     bt = Button(win, text="C", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 8, 8, 1, 1)
     bt.show()
 
     bt = Button(win, text="Wide", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 7, 7, 2)
     bt.show()
 
     win.show()
 
-def my_tb_ch(obj, data):
-    win = data
+
+### Table Repack
+def table3_cb1(obj, win):
     tb = win.data["tb"]
     b2 = win.data["b2"]
 
     tb.unpack(b2)
     tb.pack(b2, 1, 0, 1, 2)
 
+def table3_cb2(obj, win):
+    tb = win.data["tb"]
+    b2 = win.data["b2"]
+
+    tb.unpack(b2)
+    tb.pack(b2, 1, 0, 1, 1)
+
 def table3_clicked(obj, item=None):
-    win = StandardWindow("table3", "Table 3", autodel=True)
+    win = StandardWindow("table3", "Table Repack", autodel=True)
 
     tb = Table(win, size_hint_weight=EXPAND_BOTH)
     win.resize_object_add(tb)
     win.data["tb"] = tb
     tb.show()
 
-    bt = Button(win, text="Button 1", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+    bt = Button(win, text="Click me", size_hint_weight=EXPAND_BOTH,
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 0, 0, 1, 1)
     win.data["b1"] = bt
-    bt.callback_clicked_add(my_tb_ch, win)
+    bt.callback_clicked_add(table3_cb1, win)
     bt.show()
 
-    bt = Button(win, text="Button 2", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+    bt = Button(win, text="Click me", size_hint_weight=EXPAND_BOTH,
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 0, 1, 1)
     win.data["b2"] = bt
-    bt.callback_clicked_add(my_tb_ch, win)
+    bt.callback_clicked_add(table3_cb2, win)
     bt.show()
 
-    bt = Button(win, text="Button 3", size_hint_weight=EXPAND_HORIZ,
-        size_hint_align=FILL_BOTH)
+    bt = Button(win, text="Button 3", disabled=True,
+                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
     tb.pack(bt, 0, 1, 1, 1)
-    win.data["b3"] = bt
-    bt.callback_clicked_add(my_tb_ch, win)
     bt.show()
 
     win.show()
 
+
+### Table Repack 2
 def table4_clicked(obj, item=None):
-    win = StandardWindow("table4", "Table 4", autodel=True)
+    win = StandardWindow("table4", "Table Repack 2", autodel=True)
 
     tb = Table(win, size_hint_weight=EXPAND_BOTH)
     win.resize_object_add(tb)
     win.data["tb"] = tb
     tb.show()
 
-    bt = Button(win, text="Button 1", size_hint_weight=(0.25, 0.25),
-        size_hint_align=FILL_BOTH)
+    bt = Button(win, text="Click me", size_hint_weight=(0.25, 0.25),
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 0, 0, 1, 1)
     win.data["b1"] = bt
-    bt.callback_clicked_add(my_tb_ch, win)
+    bt.callback_clicked_add(table3_cb1, win)
     bt.show()
 
-    bt = Button(win, text="Button 2", size_hint_weight=(0.75, 0.25),
-        size_hint_align=FILL_BOTH)
+    bt = Button(win, text="Click me", size_hint_weight=(0.75, 0.25),
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 0, 1, 1)
     win.data["b2"] = bt
-    bt.callback_clicked_add(my_tb_ch, win)
+    bt.callback_clicked_add(table3_cb2, win)
     bt.show()
 
-    bt = Button(win, text="Button 3", size_hint_weight=(0.25, 0.75),
-        size_hint_align=FILL_BOTH)
+    bt = Button(win, text="Button 3", disabled=True,
+                size_hint_weight=(0.25, 0.75), size_hint_align=FILL_BOTH)
     tb.pack(bt, 0, 1, 1, 1)
-    win.data["b3"] = bt
-    bt.callback_clicked_add(my_tb_ch, win)
     bt.show()
 
     win.show()
 
+
+### Table Percent
 def table5_clicked(obj, item=None):
-    win = StandardWindow("table5", "Table 5", autodel=True)
+    win = StandardWindow("table5", "Table Percent", autodel=True)
 
     tb = Table(win, homogeneous=True, size_hint_weight=EXPAND_BOTH)
     win.resize_object_add(tb)
     tb.show()
 
     bt = Button(win, text="A", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 33, 0, 34, 33)
     bt.show()
 
     bt = Button(win, text="B", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 67, 33, 33, 34)
     bt.show()
 
     bt = Button(win, text="C", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 33, 67, 34, 33)
     bt.show()
 
     bt = Button(win, text="D", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 0, 33, 33, 34)
     bt.show()
 
     bt = Button(win, text="X", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 33, 33, 34, 34)
     bt.show()
 
     win.show()
 
+
+### Table Multi
 def table6_clicked(obj, item=None):
-    win = StandardWindow("table6", "Table 6", autodel=True)
+    win = StandardWindow("table6", "Table Multi", autodel=True)
 
     tb = Table(win, homogeneous=True, size_hint_weight=EXPAND_BOTH)
     win.resize_object_add(tb)
     tb.show()
 
     bt = Button(win, text="C", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 1, 2, 2)
     bt.show()
 
     bt = Button(win, text="A", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 1, 2, 2)
     bt.show()
 
     bt = Button(win, text="Blah blah blah", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 3, 0, 2, 3)
     bt.show()
 
     bt = Button(win, text="Hallow", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 0, 3, 10, 1)
     bt.show()
 
     bt = Button(win, text="B", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 1, 1, 1)
     bt.show()
 
     bt = Button(win, text="Wide", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 7, 7, 2)
     bt.show()
 
     win.show()
 
+
+### Table Multi 2
 def table7_clicked(obj, item=None):
-    win = StandardWindow("table7", "Table 7", autodel=True)
+    win = StandardWindow("table7", "Table Multi 2", autodel=True)
 
     tb = Table(win, padding=(10, 20), size_hint_weight=EXPAND_BOTH)
     win.resize_object_add(tb)
     tb.show()
 
     bt = Button(win, text="C", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 1, 2, 2)
     bt.show()
 
     bt = Button(win, text="A", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 1, 2, 2)
     bt.show()
 
     bt = Button(win, text="Blah blah blah", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 3, 0, 2, 3)
     bt.show()
 
     bt = Button(win, text="Hallow", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 0, 3, 10, 1)
     bt.show()
 
     bt = Button(win, text="B", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 1, 1, 1)
     bt.show()
 
     bt = Button(win, text="Wide", size_hint_weight=EXPAND_BOTH,
-        size_hint_align=FILL_BOTH)
+                size_hint_align=FILL_BOTH)
     tb.pack(bt, 1, 7, 7, 2)
     bt.show()
 
@@ -298,12 +313,12 @@ if __name__ == "__main__":
     items = [
         ("Table", table_clicked),
         ("Table Homogeneous", table2_clicked),
-        ("Table 3", table3_clicked),
-        ("Table 4", table4_clicked),
-        ("Table 5", table5_clicked),
-        ("Table 6", table6_clicked),
-        ("Table 7", table7_clicked),
-        ]
+        ("Table Repack", table3_clicked),
+        ("Table Repack 2", table4_clicked),
+        ("Table Percent", table5_clicked),
+        ("Table Multi", table6_clicked),
+        ("Table Multi 2", table7_clicked),
+    ]
 
     li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
     box0.pack_end(li)

-- 


Reply via email to