On Saturday 11 May 2002 09:28 pm, you wrote:
> Gary Jaffe wrote:

> >This seems to work as long as the 2 labels have the same horizontal size
> > and the 2 text entrys also have the same horizontal size.  But if one is
> > smaller, the smaller one is not drawn adjacent to the cell boundary.  Is
> > there a way I can get what I want?
> >

> >Gary
> >
> >The script I'm using is as follows.
> >
> >---------------------------------------------------------
> >#!/usr/bin/env python
> >
> >import gtk
> >
> >def delete_event(widget, event, data=None):
> >     return gtk.FALSE
> >
> >def destroy(widget, data=None):
> >     gtk.mainquit()
> >
> >win = gtk.new(gtk.GtkWindow,
> >     type=gtk.WINDOW_TOPLEVEL,
> >     title="Test Win",
> >     allow_grow=gtk.FALSE,
> >     allow_shrink=gtk.FALSE,
> >     border_width=20)
> >
> >win.connect("destroy", destroy)
> >
> >tabl = gtk.GtkTable(2, 2, gtk.FALSE)
> >win.add(tabl)
> >
> >lab00 = gtk.GtkLabel("-----Longer Label-----")
> >lab00.set_justify(gtk.JUSTIFY_RIGHT)
>
> change this line to:
>     lab00.set_alignment(1.0, 0.5)
>
> >tabl.attach(lab00, 1, 2, 0, 1, 0, 0, 0, 0)
>
> the xoptions argument should be set to gtk.FILL, so that the label gets
> allocated the full width of the table cell.
>
> >text01 = gtk.GtkEntry()
> >text01.set_usize(50, -1)
> >tabl.attach(text01, 2, 3, 0, 1, 0, 0, 0, 0)
>
> you probably want to set gtk.FILL|gtk.EXPAND as the xoptions for the
> entries, so that when you resize the window, they get the additional space.
>
> >lab10 = gtk.GtkLabel("Shorter Label")
> >lab10.set_justify(gtk.JUSTIFY_RIGHT)
>
> same here.
>
> >tabl.attach(lab10, 1, 2, 1, 2, 0, 0, 0, 0)
>
> set xoptions here too ...
>
> >text02 = gtk.GtkEntry()
> >text02.set_usize(100, -1)
> >tabl.attach(text02, 2, 3, 1, 2, 0, 0, 0, 0)
> >
> >win.show_all()
> >gtk.mainloop()
>
> James.

Thanks, James.  That does the trick.  Life is good again :-)

I couldn't find the set_alignment method when reading the docs for GtkLables 
in the GTK reference manual at 
http://developer.gnome.org/doc/API/2.0/gtk/index.html 

Is there a better place for me to read about the various methods that are 
available for the common widgets?

Gary
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to