问题
Using PyGTK, I used to be able to take a screenshot using gtk.gdk.pixbuf.get_from_drawable
.
I can't seem to figure out how to do that using PyGObject and GdkPixbuf. I've tried get_from_drawable
and get_from_window
but neither work in PyGObject.
Thanks in advance.
回答1:
Use Gtk.OffscreenWindow:
offscreen_window = Gtk.OffscreenWindow()
offscreen_window.add(widget_that_needs_screenshotting)
pixbuf = offscreen_window.get_pixbuf()
来源:https://stackoverflow.com/questions/14544500/how-do-i-take-a-screenshot-using-gdkpixbuf