Gary Jaffe wrote:
>I am new to GTK but have done some programming in python. I am having
>difficulty getting widgets to be vertically aligned. I have a 2x2 GtkTable
>and would like the 2 'GtkLabel's on the left side of the table to have their
>rightmost portion of the text to be adjacent to the boundary of the cell
>they're in. I would also like the 2 'GtkEntry's on the right side of the
>table to have leftmost portion adjacent to the boundary of the cell they're
>in.
>
>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?
>
>Thanks for any help you can give. I using:
>gtk+-1.2.9-4
>pygtk-0.6.6-7 and
>python-1.5.2-30
>on a Redhat 7.1 system.
>
>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.
--
Email: [EMAIL PROTECTED] | Linux.conf.au 2003 Call for Papers out
WWW: http://www.daa.com.au/~james/ | http://conf.linux.org.au/cfp.html
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/