[pygobject] Override Table.attach() to behave like pygtk



commit d0cbcc45366d40702c69cef207d3c0f361260c02
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Jan 16 12:16:31 2011 +0100

    Override Table.attach() to behave like pygtk
    
    It is fairly common and even gtk itself still has attach_defaults.

 gi/overrides/Gtk.py     |    3 +++
 tests/test_overrides.py |    4 ++++
 2 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 545e165..1db9025 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -1097,6 +1097,9 @@ class Table(Gtk.Table, Container):
     def __init__(self, rows=1, columns=1, homogeneous=False, **kwds):
         Gtk.Table.__init__(self, n_rows=rows, n_columns=columns, homogeneous=homogeneous, **kwds)
 
+    def attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions=Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL, xpadding=0, ypadding=0):
+        Gtk.Table.attach(self, child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding)
+
 Table = override(Table)
 __all__.append('Table')
 
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 9d2711b..ffa2517 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -838,6 +838,10 @@ class TestGtk(unittest.TestCase):
         self.assertEquals(table.get_size(), (2,3))
         self.assertEquals(table.get_homogeneous(), True)
 
+        label = Gtk.Label('Hello')
+        table.attach(label, 0, 1, 0, 1)
+        self.assertEquals(label, table.get_children()[0])
+
     def test_scrolledwindow(self):
         sw = Gtk.ScrolledWindow()
         sb = sw.get_hscrollbar()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]