Forum: Ruby-Gnome 2 justifying labels inside a table

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Joe Van D. (Guest)
on 2006-05-24 04:13
(Received via mailing list)
Hi,

I have a bunch of Gtk::Labels inside a Gtk::Table.  I want all the
labels on the left hand side of the table to be left-justified.  In
other words, all the left labels' text should be against the left
border of the table.

Any ideas?  I can't figure out how from the documentation.  I tried
adding the label to a Gtk::Alignment object, and then packing the
alignment object into a table, but that didn't work.
Mark T. (Guest)
on 2008-03-06 18:26
Joe Van D. wrote:
> Hi,
>
> I have a bunch of Gtk::Labels inside a Gtk::Table.  I want all the
> labels on the left hand side of the table to be left-justified.  In
> other words, all the left labels' text should be against the left
> border of the table.
>
> Any ideas?  I can't figure out how from the documentation.  I tried
> adding the label to a Gtk::Alignment object, and then packing the
> alignment object into a table, but that didn't work.

Set the horizontal packing of the labels to fill but not expand, then
set the x align to zero for left justification and 1 for right
justification. Hope this helps.
Miles K. (Guest)
on 2009-05-04 07:29
Is it possible to do this with other widgets inside a table such as
entry fields?
Detlef R. (Guest)
on 2009-05-04 13:34
(Received via mailing list)
am Mon, 4 May 2009 05:29:45 +0200, tat Miles K.
<removed_email_address@domain.invalid> der Welt kund:

Hi,

> Is it possible to do this with other widgets inside a table such as
> entry fields?

just put the widgets in Gtk::Alignment(s)

Cheers, detlef

--
http://det.cable.nu
Miles K. (Guest)
on 2009-05-04 15:45
Detlef R. wrote:
> am Mon, 4 May 2009 05:29:45 +0200, tat Miles K.
> <removed_email_address@domain.invalid> der Welt kund:
>
> Hi,
>
>> Is it possible to do this with other widgets inside a table such as
>> entry fields?
>
> just put the widgets in Gtk::Alignment(s)

Thanks mate.

I actually had tried that like but used :

table.attach(ef,1, 2, 1,2, Gtk::SHRINK,Gtk::SHRINK,0,0)

I'm not sure why the SHRINK screws it up but doing :

table.attach_defaults(ef,1, 2, 1,2)

works as it should.

Cheers.
Detlef R. (Guest)
on 2009-05-04 16:06
(Received via mailing list)
am Mon, 4 May 2009 13:45:24 +0200, tat Miles K.
<removed_email_address@domain.invalid> der Welt kund:

Hi,

> I actually had tried that like but used :
>
> table.attach(ef,1, 2, 1,2, Gtk::SHRINK,Gtk::SHRINK,0,0)
>
> I'm not sure why the SHRINK screws it up but doing :
>
> table.attach_defaults(ef,1, 2, 1,2)
>
> works as it should.
>

that is, cause the alignment only allocates that much space that it's
child requests. If you use Gtk::SHRINK, the alignment forwards the
"request-only-that-much-space-that-you-need" from the table cell to it's
child widget.

To get what you expect you have to use the attach_defaults or

table.attach ef,1,2,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL,0,0

Cheers, detlef

--
http://det.cable.nu
This topic is locked and can not be replied to.