Re: How can I wrap or scroll text inside a GtkLabel to keep the width?



-------- Original Message --------
Subject: How can I wrap or scroll text inside a GtkLabel to keep the width?
From: Guenther Meyer <d s e sordidmusic com>
To: gtk-app-devel-list gnome org
Date: 12/11/2008 02:22 AM

hi,

I have GtkLabels packed inside some vboxes or tables, the width of the box is determined by the size of some other elements (buttons, listviews, ...). when the text inside the labels is changed, and this text is too long to fit, the box automatically resizes, which distorts the whole window layout and pushes some widgets "off the screen". so how can I fix the width of the GtkLabel (which I don't know at creation), and let the text automatically wrap or scroll, if it doesn't fit?



gtk_label_set_line_wrap( GTK_LABEL( label ), TRUE );

However, for this to work you must set a maximum size on the label.

gtk_widget_set_size_request( GTK_WIDGET( label ), 100, -1 );

100 being 100 pixels wide. You will probably want to include an alignment and justify call so that the text always looks nice.



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