linuxgtkgnomepygobjectgtk4

Gtk4 PyGobject: Trying to snapshot GtkBox without a current allocation


I am developing an app with GTK4 + Python3 and I get this message:

Trying to snapshot GtkBox 0x5594bdcaa310 without a current allocation

It happens when I load a long list of ListBoxItems with an image in each of them. Seems kinda random, and only some of the elements throw a warning.

Sometimes the whole window even freezes, but a resizing it is enough to "unlock it"

Have you have encountered this issue? Thanks


Solution

  • I found that the issue was related to the fact that I was updating widgets that were not on screen anymore.

    It was my fault, as I was not using threading correctly.

    Please read this documentation and remember to use GLib.idle_add() every time you need to update widgets from a thread

    https://pygobject.readthedocs.io/en/latest/guide/threading.html