pixbuf_get_from_window returns same image every time.
I'm trying to update https://github.com/sublimehq/anim_encoder to work with more up to date libraries and came up wtih this for capture.py
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk, GdkPixbuf, Gtk
import time
import sys
w = Gdk.get_default_root_window().get_screen().get_active_window()
x, y, width, height = w.get_geometry()
for i in range(0, 5):
pb = Gdk.pixbuf_get_from_window(w, 0, 0, width, height)
if (pb is not None):
pb.savev(f"capture/screenshot_{time.time()}.png", "png", [], [])
print(f"Screenshot {i} saved.")
else:
print("Unable to get the screenshot.")
time.sleep(1)
This works for the first image taken, but not on any future image.
I have tried:
- moving
w
into the scope of the for loop - using the default root window instead of the active window
- using
process_all_updates
on the active window and root window - using
invalidate_rect
on the active window and root window
The only issue I could find is the follow bugzilla bug freom 2015. https://bugzilla.gnome.org/show_bug.cgi?id=754952