1

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

mijorus
  • 111
  • 1
  • 7
  • 2
    Can you provide a minimum reproducible example with source code included? – MaxPlankton May 22 '22 at 16:34
  • I'm getting similar with `Gtk-WARNING **: 13:12:37.104: Trying to snapshot GtkPicture 0x55fc95f68490 without a current allocation` widget don't render until resize. It started to happen when I added Dialog window but warning appears even though Dialog is hidden – d3im Oct 05 '22 at 11:17
  • `(python3.10:14102): Gtk-WARNING **: 15:58:06.853: Trying to snapshot __main__+MainClass 0x557e7b40e280 without a current allocation` I use threads to preload images in gui and one control thread updates images. Maybe bad app design. Should change of images be called in some kind of signal? Is there any reference for python in GTK4? Thanks – d3im Nov 04 '22 at 15:01
  • OK, maybe accessing GUI from threads created by threading package collides with main GTK thread. Is it possible? – d3im Nov 04 '22 at 15:08

1 Answers1

0

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

mijorus
  • 111
  • 1
  • 7