Re: [gtk-list] gtk_box_pack_start() and .._end() functions



Ted Milker wrote:
> 
> Hi, I've just begun working with GTK+ and I don't think I understand the
> naming conventions of the two functions above.  I'm just trying to add
> multiple buttons in a vertical column to a packing box.  Why is it that
> gtk_box_pack_start adds each button below the previous one, while
> gtk_box_pack_end adds each button on top of the previous one.  If you ask
> me, the naming of these functions implies the opposite actions.  I'm sure
> I'm just missing something obvious here.  I'm working with gtk 1.2

The _start function places the widgets at the start of the box (whether
its a vertical box where the top is the start, or horizontal where the
left side is the start).  The _end function places the widgets at the
end of the box (bottom for vertical, right for horizontal.. I think you
get the picture).  This button below previous one is probably because
you do not have any other widgets in the box (and the box does not
expand to take up the full space).


Example:

vbox = gtk_vbox_new(FALSE, 0);
...
label = gtk_label_new("Top");
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
...
label = gtk_label_new("Bottom");
gtk_box_pack_end(GTK_BOX(vbox), label, FALSE, TRUE, 0);
...
label = gtk_label_new("Bottom2");
gtk_box_pack_end(GTK_BOX(vbox), label, FALSE, TRUE, 0);


Result (in poor ASCII art):

+---------+
|   Top   |
|         |
|         |
| Bottom  |
| Bottom2 |
+---------+

Hope that helps a little.

Tim



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