in

GTK TextView has extra padding at the bottom when text is wrapped


I’ve subclassed Gtk.TextView with the following:

class GemtextWidget(Gtk.TextView):
    def __init__(self, text, *args, **kwargs):
        buf = Gtk.TextBuffer()
        buf.insert(buf.get_end_iter(), text)

        super().new_with_buffer(
            *args,
            wrap_mode=Gtk.WrapMode.WORD,
            vexpand=False,
            hexpand=False,
            editable=False,
            cursor_visible=False,
            buffer=buf,
            **kwargs
        )

When that subclass is instantiated with text (in this case from https://gemini.circumlunar.space/docs/specification.gmi), it looks like this, initially:

Upon resize, however, the correct behavior is exhibited:

Sample text in TextView with no extra vertical space

The proper behavior always occurs when the text is unwrapped, but that is of course at the cost of horizontal scrolling.

Why might extra space be present, and how can I remove it?

In case it’s helpful, here’s a screenshot full application on initial render:

Full application: many textviews, each of which have extra space below them

…and the window after a resize, making everything work properly:

Full application: many textviews, each of which are sized to fit their contents.



Source: https://stackoverflow.com/questions/70552888/gtk-textview-has-extra-padding-at-the-bottom-when-text-is-wrapped

Calculate Accuracy measures of Arima Forecasting in python

A versatile library for building CLI applications in Golang