hez
hez

Reputation: 907

In Gtk+ 3.x, how to add line-height to multi-line text label?

There's a word-wrapped, multi-line text label in a Python-based Gtk+ 3 GUI application.

    label = Gtk.Label(
        "Long text. Long text. Long text. " +
        "Long text. Long text. Long text. " +
        "Long text. Long text. Long text. " +
        "Long text. Long text. Long text. " +
        "Long text. Long text. Long text. " +
        "Long text. Long text. Long text. " +
        "Long text. Long text. Long text.",
        halign = Gtk.Align.CENTER,
        valign = Gtk.Align.CENTER,
        vexpand = True,
        margin_left = 20,
        margin_right = 20
    )
    label.set_line_wrap(True)
    grid.add(label)

The GUI mock up wants the text to use additional spacing between the lines of the label. In CSS, that would be done with the "line-height" property, but is it possible to implement this in Gtk+ 3?

Upvotes: 0

Views: 1744

Answers (1)

ptomato
ptomato

Reputation: 57854

Not possible with Gtk.Label and CSS currently. You can use a Gtk.TextView and apply a Gtk.TextTag with the pixels_inside_wrap property set.

Upvotes: 1

Related Questions