Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLib.idle_add(function) has different policies for different functions

Tags:

python

gtk

glib

I have a GTK window. It turns out that if I schedule several redraw calls all at once, without any delay, from a separate thread, using idle_add(window.queue_draw), only one call will execute.

While if I do idle_add(custom_function), every single scheduled call to custom_function will run.

While it's clear that this is done for optimization, I can't see if/where this is mentioned in the documentation [1] and I also wonder if there are other such rules for idle_add.

[1] https://developer.gnome.org/pygobject/stable/glib-functions.html

like image 706
user3496846 Avatar asked Mar 06 '26 15:03

user3496846


1 Answers

It actually isn't idle_add that is making that behavior. The docs for widget-queue-draw-region, which gets called by queue-redraw, state that redrawing only gets done after the main loop is no longer busy.

like image 115
theGtknerd Avatar answered Mar 08 '26 06:03

theGtknerd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!