Re: Setting exact size of Gtk::Label

On 09/09/11 12:34, D. R. Evans wrote:
Harry van Haaren said the following at 09/08/2011 05:29 PM :
On Thu, Sep 8, 2011 at 7:53 PM, D. R. Evans <doc evans gmail com> wrote:

How do I set the precise size of a Label?

the Label expands to show the text

Why would you *not* want this? It would result in text going "off the edge",
and not being readable...

>From the Gtk::Fixed documentation:

"The Gtk::Fixed widget is a container which can place child widgets at
fixed positions and with fixed sizes, given in pixels."

So it apparently can do exactly what I need.

Maybe I shouldn't be using Label? What's a good alternative that can indeed
be used in a Fixed with a fixed position and fixed size? I need the widget
to be able to display text and to accept events.

You seem to want a Label that may or may not display enough text to be legible, which Gtk::Fixed will do for you.  If the amount of text is variable, then it's probably wise to put it in a scrolling widget( a bog-standard TextView inside a ScrolledWindow would work nicely- as in the book).  That way when the widget is too small to make out the words, you'll still be able to scroll around.  Have a look in the manual for a working example.
If you want to capture events, you've got at least 2 options.  You can put an EventBox underneath the widget of interest- a textview or a ComboBox with entry as in the book, or you could create an empty Button and put the widget you want on it.


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