Re: Right justified text in labels




Lars Haugseth <larshau@candleweb.no> writes:

> Hi.
> 
> I'm trying to have the text inside my labels right justified. The
> labels are placed underneath each other in a table. I've tried to
> use gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT),
> the text still appear at the center of the table cell, even though
> I've expanded the label to fill the available space.

set_justify() only effects the alignment of lines for 
multi-line labels. You want:

 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

(Anybody want to write up a FAQ entry on this one?)
 
> As a workaround I've added the label to a hbox using
> gtk_box_pack_end() and then add this hbox to the table. This works
> just fine, but I'd like to know if it's possible to justify the
> text of the label without using the extra box.
> 
> Another thing I'd like to do, is to make an entry widget have a
> more narrow width than it is given by default. The maximum number
> of characters in the entry is 4, so how do I determine a reasonable
> width?

Hmmm, maybe something like:

 gtk_widget_set_usize (label,
                       gdk_string_width (label->style->font, "WWWW") + 6,
                       -1);

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]