Re: Left-justifying labels



Jonathan Hayward wrote:
How do I left-justify labels? I have labels of varying lengths packed into a vbox:

    result = gtk_vbox_new(FALSE, 0);

    sprintf(text, "Ability to learn: %ld/%ld", ag, agm);
    current_label = gtk_label_new(text);
    gtk_label_set_justify(GTK_LABEL(current_label), GTK_JUSTIFY_LEFT);
    gtk_widget_show(current_label);
    gtk_box_pack_start(GTK_BOX(result), current_label, FALSE, FALSE, 0);

[and identical (apart from the string) creation of other labels]

This shows up centered. What should I do differently?

Use g_object_set(G_OBJECT(current_label), "xalign", 0.0f, NULL) instead of the gtk_label_set_justify() call.

greets,
Benedikt



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