Re: label justification in button



On Tue, 25 Sep 2001 23:49:38 +0200, Melvin Hadasht said:

 how can one justify the label of a button ? I tried :

You'll have to make the button a bit more complex.


Let's say you want to say, "Hellloooooooo\nWorld" on a button
and make it left or right justified. First you need to know
how big you want the button to be, say you want it to be 150 by 40
pixels.  Do the following:

button = gtk_button_new();
/* Parent button to where-ever you like. */
gtk_widget_show(button);

hbox = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(button), hbox);
gtk_widget_show(hbox);

/* Now we have an hbox to align things. */
label = gtk_label_new("Hellloooooooo\nWorld");
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_widget_set_usize(label, 150, 40);
gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
gtk_widget_show(label);

Now I'm not 100% sure if gtk_widget_set_usize() should be set
for the label or the hbox, try the other if one dosen't work out right.

-- 
--
Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
.__                          ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe              '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.                "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.             __  7EMMMNNNNNWWWEEEEEEEOO.     " .
NNMMMMWWWMMMWEINMMMNn            "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
                  http://furry.ao.net/~learfox/






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