Adding rows of ellipsizable and wrappable labels into a list box (or even a normal box) results in a complete mess
Test script:
import sys
import random
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Pango
def activate(app):
window = Gtk.ApplicationWindow.new(app)
window.set_default_size(200, 300)
scroll = Gtk.ScrolledWindow()
box = Gtk.ListBox() # Same result when using a vertical Gtk.Box.
scroll.add(box)
window.add(scroll)
def add_row(text):
box.add(Gtk.Label(
label=text,
xalign=0.0,
ellipsize=Pango.EllipsizeMode.END,
wrap_mode=Pango.WrapMode.WORD_CHAR,
lines=2))
for i in range(1, 10):
add_row('This is a very long line and it should be wrapped.')
add_row('Another long line that should definitely be wrapped.')
add_row('Clearly, this long line should be wrapped as well!')
window.show_all()
app = Gtk.Application.new('org.example.Test', 0)
app.connect('activate', activate)
app.run(sys.argv)
Edited by Timm Bäder