summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--examples/gtk/sizegroup.py48
2 files changed, 52 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 23ea3b34..b6488bb5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-11-11 Johan Dahlin <jdahlin@async.com.br>
+
+ * examples/gtk/sizegroup.py: New example.
+
2005-11-09 Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
* gobject/pygobject.c (CHECK_GOBJECT): Use %p formatter instead of 0x%x.
diff --git a/examples/gtk/sizegroup.py b/examples/gtk/sizegroup.py
new file mode 100644
index 00000000..c2fd7aef
--- /dev/null
+++ b/examples/gtk/sizegroup.py
@@ -0,0 +1,48 @@
+#
+# Small example of GtkSizeGroup
+#
+# Johan Dahlin <johan@gnome.org>, 2005
+#
+
+"""Simple example that demonstrates how to use a GtkSizeGroup.
+
+In this case we'll have two labels and two entries.
+The labels have different width, but we'd like to have the entries
+aligned vertically. We can accomplish this by adding a horizontal
+sizegroup to the labels.
+"""
+
+import gtk
+
+def create_label(text):
+ hbox = gtk.HBox(spacing=6)
+ label = gtk.Label(text)
+ hbox.pack_start(label)
+ entry = gtk.Entry()
+ hbox.pack_start(entry)
+ return hbox, label
+
+def main():
+ win = gtk.Window()
+ win.connect('delete-event', gtk.main_quit)
+ win.set_border_width(6)
+ win.set_title('GtkSizeGroup example')
+
+ vbox = gtk.VBox(spacing=6)
+ win.add(vbox)
+
+ sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
+
+ hbox, label = create_label('Name:')
+ sg.add_widget(label)
+ vbox.pack_start(hbox)
+
+ hbox, label = create_label('Address:')
+ sg.add_widget(label)
+ vbox.pack_start(hbox)
+
+ win.show_all()
+ gtk.main()
+
+if __name__ == '__main__':
+ main()