diff options
author | Johan Dahlin <johan@src.gnome.org> | 2005-11-11 16:37:19 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2005-11-11 16:37:19 +0000 |
commit | 9fbf3ad482b90d57f4a81e288a78ceab202891fb (patch) | |
tree | 7094d614e720bd9bcfde4c03947937f22468eee0 /examples | |
parent | 6df1c5518398c3d21db7183f7dfeac0f4db52d27 (diff) | |
download | pygtk-9fbf3ad482b90d57f4a81e288a78ceab202891fb.tar.gz |
New example.
* examples/gtk/sizegroup.py: New example.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gtk/sizegroup.py | 48 |
1 files changed, 48 insertions, 0 deletions
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() |